Procházet zdrojové kódy

Add Auth Routes Documentation

Erwan ROUSSEL před 7 roky
rodič
revize
8b81bcd1e6
1 změnil soubory, kde provedl 16 přidání a 0 odebrání
  1. 16 0
      routes/user/auth.go

+ 16 - 0
routes/user/auth.go

@@ -68,6 +68,7 @@ func AutoLogin(c *context.Context) (bool, error) {
 	return true, nil
 }
 
+//Login is the handler for "/login"
 func Login(c *context.Context) {
 	c.Title("sign_in")
 
@@ -116,6 +117,7 @@ func Login(c *context.Context) {
 	c.Success(LOGIN)
 }
 
+//afterLogin set sessions cookies and redirect to "/"
 func afterLogin(c *context.Context, u *models.User, remember bool) {
 	if remember {
 		days := 86400 * setting.LoginRememberDays
@@ -144,6 +146,7 @@ func afterLogin(c *context.Context, u *models.User, remember bool) {
 	c.SubURLRedirect("/")
 }
 
+//LoginPost is the POST handler for "/login"
 func LoginPost(c *context.Context, f form.SignIn) {
 	c.Title("sign_in")
 
@@ -196,6 +199,7 @@ func LoginPost(c *context.Context, f form.SignIn) {
 	c.SubURLRedirect("/login/two_factor")
 }
 
+//LoginTwoFactor is the handler for "/login" with two factors authentication
 func LoginTwoFactor(c *context.Context) {
 	_, ok := c.Session.Get("twoFactorUserID").(int64)
 	if !ok {
@@ -206,6 +210,7 @@ func LoginTwoFactor(c *context.Context) {
 	c.Success(TWO_FACTOR)
 }
 
+//LoginTwoFactorPost is the POST handler for "/login" with two factors authentication
 func LoginTwoFactorPost(c *context.Context) {
 	userID, ok := c.Session.Get("twoFactorUserID").(int64)
 	if !ok {
@@ -249,6 +254,7 @@ func LoginTwoFactorPost(c *context.Context) {
 	afterLogin(c, u, c.Session.Get("twoFactorRemember").(bool))
 }
 
+//LoginTwoFactorRecoveryCode is the handler to recover Two Factor Code
 func LoginTwoFactorRecoveryCode(c *context.Context) {
 	_, ok := c.Session.Get("twoFactorUserID").(int64)
 	if !ok {
@@ -259,6 +265,7 @@ func LoginTwoFactorRecoveryCode(c *context.Context) {
 	c.Success(TWO_FACTOR_RECOVERY_CODE)
 }
 
+//LoginTwoFactorRecoveryCodePost is the POST handler to recover Two Factor Code
 func LoginTwoFactorRecoveryCodePost(c *context.Context) {
 	userID, ok := c.Session.Get("twoFactorUserID").(int64)
 	if !ok {
@@ -284,6 +291,7 @@ func LoginTwoFactorRecoveryCodePost(c *context.Context) {
 	afterLogin(c, u, c.Session.Get("twoFactorRemember").(bool))
 }
 
+//SignOut is the handler for "/user/logout"
 func SignOut(c *context.Context) {
 	c.Session.Delete("uid")
 	c.Session.Delete("uname")
@@ -293,6 +301,7 @@ func SignOut(c *context.Context) {
 	c.SubURLRedirect("/")
 }
 
+//SignUp is the handler for "/signup"
 func SignUp(c *context.Context) {
 	c.Title("sign_up")
 
@@ -307,6 +316,7 @@ func SignUp(c *context.Context) {
 	c.Success(SIGNUP)
 }
 
+//SignUpPost is the POST handler for "/join"
 func SignUpPost(c *context.Context, cpt *captcha.Captcha, f form.Register) {
 	c.Title("sign_up")
 
@@ -393,6 +403,7 @@ func SignUpPost(c *context.Context, cpt *captcha.Captcha, f form.Register) {
 	c.SubURLRedirect("/login")
 }
 
+//Activate activates the code
 func Activate(c *context.Context) {
 	code := c.Query("code")
 	if len(code) == 0 {
@@ -445,6 +456,7 @@ func Activate(c *context.Context) {
 	c.Success(ACTIVATE)
 }
 
+//ActivateEmail is the handler to activate the user email
 func ActivateEmail(c *context.Context) {
 	code := c.Query("code")
 	email_string := c.Query("email")
@@ -463,6 +475,7 @@ func ActivateEmail(c *context.Context) {
 	return
 }
 
+//ForgotPasswd is the handler for "/user/forget_password"
 func ForgotPasswd(c *context.Context) {
 	c.Title("auth.forgot_password")
 
@@ -476,6 +489,7 @@ func ForgotPasswd(c *context.Context) {
 	c.Success(FORGOT_PASSWORD)
 }
 
+//ForgotPasswdPost is the POST handler for "/user/forget_password"
 func ForgotPasswdPost(c *context.Context) {
 	c.Title("auth.forgot_password")
 
@@ -523,6 +537,7 @@ func ForgotPasswdPost(c *context.Context) {
 	c.Success(FORGOT_PASSWORD)
 }
 
+//ResetPasswd is the handler to reset your password
 func ResetPasswd(c *context.Context) {
 	c.Title("auth.reset_password")
 
@@ -536,6 +551,7 @@ func ResetPasswd(c *context.Context) {
 	c.Success(RESET_PASSWORD)
 }
 
+//ResetPasswdPost is the POST handler to reset your password
 func ResetPasswdPost(c *context.Context) {
 	c.Title("auth.reset_password")