|
|
@ -82,10 +82,7 @@ func SignIn(ctx *middleware.Context, form auth.LogInForm) { |
|
|
|
user, err := models.LoginUserPlain(form.UserName, form.Password) |
|
|
|
user, err := models.LoginUserPlain(form.UserName, form.Password) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
if err.Error() == models.ErrUserNotExist.Error() { |
|
|
|
if err.Error() == models.ErrUserNotExist.Error() { |
|
|
|
ctx.Data["HasError"] = true |
|
|
|
ctx.RenderWithErr("Username or password is not correct", "user/signin", &form) |
|
|
|
ctx.Data["ErrorMsg"] = "Username or password is not correct" |
|
|
|
|
|
|
|
auth.AssignForm(form, ctx.Data) |
|
|
|
|
|
|
|
ctx.Render.HTML(200, "user/signin", ctx.Data) |
|
|
|
|
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -121,7 +118,7 @@ func SignUp(ctx *middleware.Context, form auth.RegisterForm) { |
|
|
|
auth.AssignForm(form, ctx.Data) |
|
|
|
auth.AssignForm(form, ctx.Data) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if hasErr, ok := ctx.Data["HasError"]; ok && hasErr.(bool) { |
|
|
|
if ctx.HasError() { |
|
|
|
ctx.Render.HTML(200, "user/signup", ctx.Data) |
|
|
|
ctx.Render.HTML(200, "user/signup", ctx.Data) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
@ -133,18 +130,11 @@ func SignUp(ctx *middleware.Context, form auth.RegisterForm) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if err := models.RegisterUser(u); err != nil { |
|
|
|
if err := models.RegisterUser(u); err != nil { |
|
|
|
ctx.Data["HasError"] = true |
|
|
|
|
|
|
|
auth.AssignForm(form, ctx.Data) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch err.Error() { |
|
|
|
switch err.Error() { |
|
|
|
case models.ErrUserAlreadyExist.Error(): |
|
|
|
case models.ErrUserAlreadyExist.Error(): |
|
|
|
ctx.Data["Err_Username"] = true |
|
|
|
ctx.RenderWithErr("Username has been already taken", "user/signup", &form) |
|
|
|
ctx.Data["ErrorMsg"] = "Username has been already taken" |
|
|
|
|
|
|
|
ctx.Render.HTML(200, "user/signup", ctx.Data) |
|
|
|
|
|
|
|
case models.ErrEmailAlreadyUsed.Error(): |
|
|
|
case models.ErrEmailAlreadyUsed.Error(): |
|
|
|
ctx.Data["Err_Email"] = true |
|
|
|
ctx.RenderWithErr("E-mail address has been already used", "user/signup", &form) |
|
|
|
ctx.Data["ErrorMsg"] = "E-mail address has been already used" |
|
|
|
|
|
|
|
ctx.Render.HTML(200, "user/signup", ctx.Data) |
|
|
|
|
|
|
|
default: |
|
|
|
default: |
|
|
|
ctx.Handle(200, "user.SignUp", err) |
|
|
|
ctx.Handle(200, "user.SignUp", err) |
|
|
|
} |
|
|
|
} |
|
|
|