Changed from http to rabbitmq
parent
ff9de3baa5
commit
28eaa95267
|
@ -1,14 +1,11 @@
|
||||||
package user
|
package user
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
|
||||||
"math/big"
|
"math/big"
|
||||||
"net/http"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
@ -16,6 +13,7 @@ import (
|
||||||
|
|
||||||
"git.umbach.dev/app-idea/rest-api/modules/config"
|
"git.umbach.dev/app-idea/rest-api/modules/config"
|
||||||
"git.umbach.dev/app-idea/rest-api/modules/database"
|
"git.umbach.dev/app-idea/rest-api/modules/database"
|
||||||
|
"git.umbach.dev/app-idea/rest-api/modules/rabbitmq"
|
||||||
"git.umbach.dev/app-idea/rest-api/modules/structs"
|
"git.umbach.dev/app-idea/rest-api/modules/structs"
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
|
@ -28,10 +26,11 @@ import (
|
||||||
var cfg = &config.Cfg
|
var cfg = &config.Cfg
|
||||||
|
|
||||||
type LoginInput struct {
|
type LoginInput struct {
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
Password string `json:"password"`
|
Password string `json:"password"`
|
||||||
Hashtag string `json:"hashtag"`
|
Hashtag string `json:"hashtag"`
|
||||||
|
LanguageId int `json:"languageId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewUser(c *fiber.Ctx) error {
|
func NewUser(c *fiber.Ctx) error {
|
||||||
|
@ -127,7 +126,10 @@ func NewUser(c *fiber.Ctx) error {
|
||||||
user.Hashtag = input.Hashtag
|
user.Hashtag = input.Hashtag
|
||||||
user.Name = input.Username
|
user.Name = input.Username
|
||||||
user.Password = string(hashedPassword)
|
user.Password = string(hashedPassword)
|
||||||
user.Language = 0
|
|
||||||
|
log.Debugln("lgId", input.LanguageId)
|
||||||
|
|
||||||
|
user.LanguageId = input.LanguageId
|
||||||
user.LastLogin = now
|
user.LastLogin = now
|
||||||
user.CreatedAt = now
|
user.CreatedAt = now
|
||||||
|
|
||||||
|
@ -152,7 +154,7 @@ func NewUser(c *fiber.Ctx) error {
|
||||||
"email": "` + user.Email + `",
|
"email": "` + user.Email + `",
|
||||||
"url": "https://roese.dev/activate/1234567890"}`)
|
"url": "https://roese.dev/activate/1234567890"}`)
|
||||||
|
|
||||||
js := JsonMessage{Key: "mykey", Mail: "app@roese.dev", TemplateId: 0, LanguageId: 0, BodyData: &bodyData}
|
js := JsonMessage{Key: "mykey", Mail: "app@roese.dev", TemplateId: 0, LanguageId: user.LanguageId, BodyData: &bodyData}
|
||||||
|
|
||||||
reqBody, err := json.MarshalIndent(&js, "", "\t")
|
reqBody, err := json.MarshalIndent(&js, "", "\t")
|
||||||
|
|
||||||
|
@ -160,7 +162,9 @@ func NewUser(c *fiber.Ctx) error {
|
||||||
log.Infoln("error reqBody", err)
|
log.Infoln("error reqBody", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := http.Post(cfg.Mail.Host+"/send", "application/json", bytes.NewBuffer(reqBody))
|
rabbitmq.Publish(string(reqBody))
|
||||||
|
|
||||||
|
/*resp, err := http.Post(cfg.Mail.Host+"/send", "application/json", bytes.NewBuffer(reqBody))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Infoln("err http post", err)
|
log.Infoln("err http post", err)
|
||||||
|
@ -175,7 +179,7 @@ func NewUser(c *fiber.Ctx) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Infoln("body", body)
|
log.Infoln("body", body)
|
||||||
log.Infoln("StatusCode", resp.StatusCode)
|
log.Infoln("StatusCode", resp.StatusCode)*/
|
||||||
|
|
||||||
sessionId, err := createUserSession(db, user.Id, c.IP(), string(c.Context().UserAgent()))
|
sessionId, err := createUserSession(db, user.Id, c.IP(), string(c.Context().UserAgent()))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue