Added LanguageId to user registration
parent
3fd1c62ef7
commit
76bb6332c9
|
@ -123,10 +123,11 @@ func NewUser(c *fiber.Ctx) error {
|
|||
|
||||
now := time.Now()
|
||||
|
||||
user.ID = strings.Replace(uuid.New().String(), "-", "", -1)
|
||||
user.Id = strings.Replace(uuid.New().String(), "-", "", -1)
|
||||
user.Hashtag = input.Hashtag
|
||||
user.Name = input.Username
|
||||
user.Password = string(hashedPassword)
|
||||
user.Language = 0
|
||||
user.LastLogin = now
|
||||
user.CreatedAt = now
|
||||
|
||||
|
@ -176,7 +177,7 @@ func NewUser(c *fiber.Ctx) error {
|
|||
log.Infoln("body", body)
|
||||
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()))
|
||||
|
||||
if err != nil {
|
||||
return c.SendStatus(fiber.StatusInternalServerError)
|
||||
|
@ -266,7 +267,7 @@ func isUpper(s string) bool {
|
|||
}
|
||||
|
||||
func isUsernameValid(u string) bool {
|
||||
if len(u) < int(cfg.Settings.UsernameMinLen) || len(u) > int(cfg.Settings.UsernameMaxLen) {
|
||||
if len(u) < int(cfg.Settings.Lengths.UsernameMinLen) || len(u) > int(cfg.Settings.Lengths.UsernameMaxLen) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
|
@ -275,14 +276,14 @@ func isUsernameValid(u string) bool {
|
|||
var emailRegex = regexp.MustCompile("^[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$")
|
||||
|
||||
func isEmailValid(e string) bool {
|
||||
if len(e) < int(cfg.Settings.EmailMinLen) || len(e) > int(cfg.Settings.EmailMaxLen) {
|
||||
if len(e) < int(cfg.Settings.Lengths.EmailMinLen) || len(e) > int(cfg.Settings.Lengths.EmailMaxLen) {
|
||||
return false
|
||||
}
|
||||
return emailRegex.MatchString(e)
|
||||
}
|
||||
|
||||
func isPasswordValid(p string) bool {
|
||||
if len(p) < int(cfg.Settings.PasswordMinLen) || len(p) > int(cfg.Settings.PasswordMaxLen) {
|
||||
if len(p) < int(cfg.Settings.Lengths.PasswordMinLen) || len(p) > int(cfg.Settings.Lengths.PasswordMaxLen) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
|
@ -431,7 +432,7 @@ func Login(c *fiber.Ctx) error {
|
|||
return c.SendStatus(fiber.StatusUnauthorized)
|
||||
}
|
||||
|
||||
sessionId, err := createUserSession(database.DB, user.ID, c.IP(), string(c.Context().UserAgent()))
|
||||
sessionId, err := createUserSession(database.DB, user.Id, c.IP(), string(c.Context().UserAgent()))
|
||||
|
||||
if err != nil {
|
||||
return c.SendStatus(fiber.StatusInternalServerError)
|
||||
|
|
Loading…
Reference in New Issue