|
@@ -69,6 +69,7 @@ func AutoLogin(c *context.Context) (bool, error) {
|
|
|
return true, nil
|
|
return true, nil
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+//Login is the handler for "/login"
|
|
|
func Login(c *context.Context) {
|
|
func Login(c *context.Context) {
|
|
|
c.Title("sign_in")
|
|
c.Title("sign_in")
|
|
|
|
|
|
|
@@ -117,6 +118,7 @@ func Login(c *context.Context) {
|
|
|
c.Success(LOGIN)
|
|
c.Success(LOGIN)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+//afterLogin set sessions cookies and redirect to "/"
|
|
|
func afterLogin(c *context.Context, u *models.User, remember bool) {
|
|
func afterLogin(c *context.Context, u *models.User, remember bool) {
|
|
|
if remember {
|
|
if remember {
|
|
|
days := 86400 * setting.LoginRememberDays
|
|
days := 86400 * setting.LoginRememberDays
|
|
@@ -145,6 +147,7 @@ func afterLogin(c *context.Context, u *models.User, remember bool) {
|
|
|
c.SubURLRedirect("/")
|
|
c.SubURLRedirect("/")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+//LoginPost is the POST handler for "/login"
|
|
|
func LoginPost(c *context.Context, f form.SignIn) {
|
|
func LoginPost(c *context.Context, f form.SignIn) {
|
|
|
c.Title("sign_in")
|
|
c.Title("sign_in")
|
|
|
|
|
|
|
@@ -197,6 +200,7 @@ func LoginPost(c *context.Context, f form.SignIn) {
|
|
|
c.SubURLRedirect("/login/two_factor")
|
|
c.SubURLRedirect("/login/two_factor")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+//LoginTwoFactor is the handler for "/login" with two factors authentication
|
|
|
func LoginTwoFactor(c *context.Context) {
|
|
func LoginTwoFactor(c *context.Context) {
|
|
|
_, ok := c.Session.Get("twoFactorUserID").(int64)
|
|
_, ok := c.Session.Get("twoFactorUserID").(int64)
|
|
|
if !ok {
|
|
if !ok {
|
|
@@ -207,6 +211,7 @@ func LoginTwoFactor(c *context.Context) {
|
|
|
c.Success(TWO_FACTOR)
|
|
c.Success(TWO_FACTOR)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+//LoginTwoFactorPost is the POST handler for "/login" with two factors authentication
|
|
|
func LoginTwoFactorPost(c *context.Context) {
|
|
func LoginTwoFactorPost(c *context.Context) {
|
|
|
userID, ok := c.Session.Get("twoFactorUserID").(int64)
|
|
userID, ok := c.Session.Get("twoFactorUserID").(int64)
|
|
|
if !ok {
|
|
if !ok {
|
|
@@ -251,6 +256,7 @@ func LoginTwoFactorPost(c *context.Context) {
|
|
|
afterLogin(c, u, c.Session.Get("twoFactorRemember").(bool))
|
|
afterLogin(c, u, c.Session.Get("twoFactorRemember").(bool))
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+//LoginTwoFactorRecoveryCode is the handler to recover Two Factor Code
|
|
|
func LoginTwoFactorRecoveryCode(c *context.Context) {
|
|
func LoginTwoFactorRecoveryCode(c *context.Context) {
|
|
|
_, ok := c.Session.Get("twoFactorUserID").(int64)
|
|
_, ok := c.Session.Get("twoFactorUserID").(int64)
|
|
|
if !ok {
|
|
if !ok {
|
|
@@ -261,6 +267,7 @@ func LoginTwoFactorRecoveryCode(c *context.Context) {
|
|
|
c.Success(TWO_FACTOR_RECOVERY_CODE)
|
|
c.Success(TWO_FACTOR_RECOVERY_CODE)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+//LoginTwoFactorRecoveryCodePost is the POST handler to recover Two Factor Code
|
|
|
func LoginTwoFactorRecoveryCodePost(c *context.Context) {
|
|
func LoginTwoFactorRecoveryCodePost(c *context.Context) {
|
|
|
userID, ok := c.Session.Get("twoFactorUserID").(int64)
|
|
userID, ok := c.Session.Get("twoFactorUserID").(int64)
|
|
|
if !ok {
|
|
if !ok {
|
|
@@ -286,6 +293,7 @@ func LoginTwoFactorRecoveryCodePost(c *context.Context) {
|
|
|
afterLogin(c, u, c.Session.Get("twoFactorRemember").(bool))
|
|
afterLogin(c, u, c.Session.Get("twoFactorRemember").(bool))
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+//SignOut is the handler for "/user/logout"
|
|
|
func SignOut(c *context.Context) {
|
|
func SignOut(c *context.Context) {
|
|
|
c.Session.Delete("uid")
|
|
c.Session.Delete("uid")
|
|
|
c.Session.Delete("uname")
|
|
c.Session.Delete("uname")
|
|
@@ -295,6 +303,7 @@ func SignOut(c *context.Context) {
|
|
|
c.SubURLRedirect("/")
|
|
c.SubURLRedirect("/")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+//SignUp is the handler for "/signup"
|
|
|
func SignUp(c *context.Context) {
|
|
func SignUp(c *context.Context) {
|
|
|
c.Title("sign_up")
|
|
c.Title("sign_up")
|
|
|
|
|
|
|
@@ -309,6 +318,7 @@ func SignUp(c *context.Context) {
|
|
|
c.Success(SIGNUP)
|
|
c.Success(SIGNUP)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+//SignUpPost is the POST handler for "/join"
|
|
|
func SignUpPost(c *context.Context, cpt *captcha.Captcha, f form.Register) {
|
|
func SignUpPost(c *context.Context, cpt *captcha.Captcha, f form.Register) {
|
|
|
c.Title("sign_up")
|
|
c.Title("sign_up")
|
|
|
|
|
|
|
@@ -396,6 +406,7 @@ func SignUpPost(c *context.Context, cpt *captcha.Captcha, f form.Register) {
|
|
|
c.SubURLRedirect("/login")
|
|
c.SubURLRedirect("/login")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+//Activate activates the code
|
|
|
func Activate(c *context.Context) {
|
|
func Activate(c *context.Context) {
|
|
|
code := c.Query("code")
|
|
code := c.Query("code")
|
|
|
if len(code) == 0 {
|
|
if len(code) == 0 {
|
|
@@ -449,6 +460,7 @@ func Activate(c *context.Context) {
|
|
|
c.Success(ACTIVATE)
|
|
c.Success(ACTIVATE)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+//ActivateEmail is the handler to activate the user email
|
|
|
func ActivateEmail(c *context.Context) {
|
|
func ActivateEmail(c *context.Context) {
|
|
|
code := c.Query("code")
|
|
code := c.Query("code")
|
|
|
email_string := c.Query("email")
|
|
email_string := c.Query("email")
|
|
@@ -467,6 +479,7 @@ func ActivateEmail(c *context.Context) {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+//ForgotPasswd is the handler for "/user/forget_password"
|
|
|
func ForgotPasswd(c *context.Context) {
|
|
func ForgotPasswd(c *context.Context) {
|
|
|
c.Title("auth.forgot_password")
|
|
c.Title("auth.forgot_password")
|
|
|
|
|
|
|
@@ -480,6 +493,7 @@ func ForgotPasswd(c *context.Context) {
|
|
|
c.Success(FORGOT_PASSWORD)
|
|
c.Success(FORGOT_PASSWORD)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+//ForgotPasswdPost is the POST handler for "/user/forget_password"
|
|
|
func ForgotPasswdPost(c *context.Context) {
|
|
func ForgotPasswdPost(c *context.Context) {
|
|
|
c.Title("auth.forgot_password")
|
|
c.Title("auth.forgot_password")
|
|
|
|
|
|
|
@@ -528,6 +542,7 @@ func ForgotPasswdPost(c *context.Context) {
|
|
|
c.Success(FORGOT_PASSWORD)
|
|
c.Success(FORGOT_PASSWORD)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+//ResetPasswd is the handler to reset your password
|
|
|
func ResetPasswd(c *context.Context) {
|
|
func ResetPasswd(c *context.Context) {
|
|
|
c.Title("auth.reset_password")
|
|
c.Title("auth.reset_password")
|
|
|
|
|
|
|
@@ -541,6 +556,7 @@ func ResetPasswd(c *context.Context) {
|
|
|
c.Success(RESET_PASSWORD)
|
|
c.Success(RESET_PASSWORD)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+//ResetPasswdPost is the POST handler to reset your password
|
|
|
func ResetPasswdPost(c *context.Context) {
|
|
func ResetPasswdPost(c *context.Context) {
|
|
|
c.Title("auth.reset_password")
|
|
c.Title("auth.reset_password")
|
|
|
|
|
|