Changed from http to rabbitmq
parent
ff9de3baa5
commit
28eaa95267
|
@ -1,14 +1,11 @@
|
|||
package user
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/rand"
|
||||
"database/sql"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"math/big"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
@ -16,6 +13,7 @@ import (
|
|||
|
||||
"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/rabbitmq"
|
||||
"git.umbach.dev/app-idea/rest-api/modules/structs"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/google/uuid"
|
||||
|
@ -28,10 +26,11 @@ import (
|
|||
var cfg = &config.Cfg
|
||||
|
||||
type LoginInput struct {
|
||||
Username string `json:"username"`
|
||||
Email string `json:"email"`
|
||||
Password string `json:"password"`
|
||||
Hashtag string `json:"hashtag"`
|
||||
Username string `json:"username"`
|
||||
Email string `json:"email"`
|
||||
Password string `json:"password"`
|
||||
Hashtag string `json:"hashtag"`
|
||||
LanguageId int `json:"languageId"`
|
||||
}
|
||||
|
||||
func NewUser(c *fiber.Ctx) error {
|
||||
|
@ -127,7 +126,10 @@ func NewUser(c *fiber.Ctx) error {
|
|||
user.Hashtag = input.Hashtag
|
||||
user.Name = input.Username
|
||||
user.Password = string(hashedPassword)
|
||||
user.Language = 0
|
||||
|
||||
log.Debugln("lgId", input.LanguageId)
|
||||
|
||||
user.LanguageId = input.LanguageId
|
||||
user.LastLogin = now
|
||||
user.CreatedAt = now
|
||||
|
||||
|
@ -152,7 +154,7 @@ func NewUser(c *fiber.Ctx) error {
|
|||
"email": "` + user.Email + `",
|
||||
"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")
|
||||
|
||||
|
@ -160,7 +162,9 @@ func NewUser(c *fiber.Ctx) error {
|
|||
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 {
|
||||
log.Infoln("err http post", err)
|
||||
|
@ -175,7 +179,7 @@ func NewUser(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
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()))
|
||||
|
||||
|
|
Loading…
Reference in New Issue