diff options
author | Sandro Santilli <strk@kbt.io> | 2017-03-21 01:55:00 +0100 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2017-03-21 08:55:00 +0800 |
commit | f73e7344111645b836e767bbf80b96834651805f (patch) | |
tree | 0315cb59a9b56bcb594d2cd4dccf385557e834ba /routers | |
parent | 888dee3b5f931062ea97e57130b26d1943e5173e (diff) | |
download | gitea-f73e7344111645b836e767bbf80b96834651805f.tar.gz gitea-f73e7344111645b836e767bbf80b96834651805f.zip |
Run "make fmt" with go-1.6 (#1333)
Diffstat (limited to 'routers')
-rw-r--r-- | routers/user/auth_openid.go | 41 | ||||
-rw-r--r-- | routers/user/setting_openid.go | 25 |
2 files changed, 33 insertions, 33 deletions
diff --git a/routers/user/auth_openid.go b/routers/user/auth_openid.go index 19c1548399..c5575814f1 100644 --- a/routers/user/auth_openid.go +++ b/routers/user/auth_openid.go @@ -102,23 +102,24 @@ func SignInOpenIDPost(ctx *context.Context, form auth.SignInOpenIDForm) { id, err := openid.Normalize(form.Openid) if err != nil { ctx.RenderWithErr(err.Error(), tplSignInOpenID, &form) - return; + return } form.Openid = id log.Trace("OpenID uri: " + id) - err = allowedOpenIDURI(id); if err != nil { + err = allowedOpenIDURI(id) + if err != nil { ctx.RenderWithErr(err.Error(), tplSignInOpenID, &form) - return; + return } redirectTo := setting.AppURL + "user/login/openid" url, err := openid.RedirectURL(id, redirectTo, setting.AppURL) - if err != nil { + if err != nil { ctx.RenderWithErr(err.Error(), tplSignInOpenID, &form) - return; - } + return + } // Request optional nickname and email info // NOTE: change to `openid.sreg.required` to require it @@ -134,10 +135,10 @@ func SignInOpenIDPost(ctx *context.Context, form auth.SignInOpenIDForm) { // signInOpenIDVerify handles response from OpenID provider func signInOpenIDVerify(ctx *context.Context) { - log.Trace("Incoming call to: " + ctx.Req.Request.URL.String()) + log.Trace("Incoming call to: " + ctx.Req.Request.URL.String()) - fullURL := setting.AppURL + ctx.Req.Request.URL.String()[1:] - log.Trace("Full URL: " + fullURL) + fullURL := setting.AppURL + ctx.Req.Request.URL.String()[1:] + log.Trace("Full URL: " + fullURL) var id, err = openid.Verify(fullURL) if err != nil { @@ -154,7 +155,7 @@ func signInOpenIDVerify(ctx *context.Context) { u, _ := models.GetUserByOpenID(id) if err != nil { - if ! models.IsErrUserNotExist(err) { + if !models.IsErrUserNotExist(err) { ctx.RenderWithErr(err.Error(), tplSignInOpenID, &auth.SignInOpenIDForm{ Openid: id, }) @@ -188,12 +189,12 @@ func signInOpenIDVerify(ctx *context.Context) { email := values.Get("openid.sreg.email") nickname := values.Get("openid.sreg.nickname") - log.Trace("User has email=" + email + " and nickname=" + nickname) + log.Trace("User has email=" + email + " and nickname=" + nickname) if email != "" { u, _ = models.GetUserByEmail(email) if err != nil { - if ! models.IsErrUserNotExist(err) { + if !models.IsErrUserNotExist(err) { ctx.RenderWithErr(err.Error(), tplSignInOpenID, &auth.SignInOpenIDForm{ Openid: id, }) @@ -208,7 +209,7 @@ func signInOpenIDVerify(ctx *context.Context) { if u == nil && nickname != "" { u, _ = models.GetUserByName(nickname) if err != nil { - if ! models.IsErrUserNotExist(err) { + if !models.IsErrUserNotExist(err) { ctx.RenderWithErr(err.Error(), tplSignInOpenID, &auth.SignInOpenIDForm{ Openid: id, }) @@ -230,7 +231,7 @@ func signInOpenIDVerify(ctx *context.Context) { ctx.Session.Set("openid_determined_username", nickname) - if u != nil || ! setting.EnableOpenIDSignUp { + if u != nil || !setting.EnableOpenIDSignUp { ctx.Redirect(setting.AppSubURL + "/user/openid/connect") } else { ctx.Redirect(setting.AppSubURL + "/user/openid/register") @@ -280,7 +281,7 @@ func ConnectOpenIDPost(ctx *context.Context, form auth.ConnectOpenIDForm) { } // add OpenID for the user - userOID := &models.UserOpenID{UID:u.ID, URI:oid} + userOID := &models.UserOpenID{UID: u.ID, URI: oid} if err = models.AddUserOpenID(userOID); err != nil { if models.IsErrOpenIDAlreadyUsed(err) { ctx.RenderWithErr(ctx.Tr("form.openid_been_used", oid), tplConnectOID, &form) @@ -299,7 +300,7 @@ func ConnectOpenIDPost(ctx *context.Context, form auth.ConnectOpenIDForm) { // RegisterOpenID shows a form to create a new user authenticated via an OpenID URI func RegisterOpenID(ctx *context.Context) { - if ! setting.EnableOpenIDSignUp { + if !setting.EnableOpenIDSignUp { ctx.Error(403) return } @@ -327,7 +328,7 @@ func RegisterOpenID(ctx *context.Context) { // RegisterOpenIDPost handles submission of a form to create a new user authenticated via an OpenID URI func RegisterOpenIDPost(ctx *context.Context, cpt *captcha.Captcha, form auth.SignUpOpenIDForm) { - if ! setting.EnableOpenIDSignUp { + if !setting.EnableOpenIDSignUp { ctx.Error(403) return } @@ -351,7 +352,9 @@ func RegisterOpenIDPost(ctx *context.Context, cpt *captcha.Captcha, form auth.Si } len := setting.MinPasswordLength - if len < 256 { len = 256 } + if len < 256 { + len = 256 + } password, err := base.GetRandomString(len) if err != nil { ctx.RenderWithErr(err.Error(), tplSignUpOID, form) @@ -387,7 +390,7 @@ func RegisterOpenIDPost(ctx *context.Context, cpt *captcha.Captcha, form auth.Si log.Trace("Account created: %s", u.Name) // add OpenID for the user - userOID := &models.UserOpenID{UID:u.ID, URI:oid} + userOID := &models.UserOpenID{UID: u.ID, URI: oid} if err = models.AddUserOpenID(userOID); err != nil { if models.IsErrOpenIDAlreadyUsed(err) { ctx.RenderWithErr(ctx.Tr("form.openid_been_used", oid), tplSignUpOID, &form) diff --git a/routers/user/setting_openid.go b/routers/user/setting_openid.go index e33ab144ed..b39278d7c3 100644 --- a/routers/user/setting_openid.go +++ b/routers/user/setting_openid.go @@ -5,7 +5,6 @@ package user import ( - "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/auth" "code.gitea.io/gitea/modules/auth/openid" @@ -16,7 +15,7 @@ import ( ) const ( - tplSettingsOpenID base.TplName = "user/settings/openid" + tplSettingsOpenID base.TplName = "user/settings/openid" ) // SettingsOpenID renders change user's openid page @@ -64,10 +63,10 @@ func SettingsOpenIDPost(ctx *context.Context, form auth.AddOpenIDForm) { id, err := openid.Normalize(form.Openid) if err != nil { ctx.RenderWithErr(err.Error(), tplSettingsOpenID, &form) - return; + return } form.Openid = id - log.Trace("Normalized id: " + id) + log.Trace("Normalized id: " + id) oids, err := models.GetUserOpenIDs(ctx.User.ID) if err != nil { @@ -84,21 +83,20 @@ func SettingsOpenIDPost(ctx *context.Context, form auth.AddOpenIDForm) { } } - redirectTo := setting.AppURL + "user/settings/openid" url, err := openid.RedirectURL(id, redirectTo, setting.AppURL) - if err != nil { + if err != nil { ctx.RenderWithErr(err.Error(), tplSettingsOpenID, &form) - return; - } + return + } ctx.Redirect(url) } func settingsOpenIDVerify(ctx *context.Context) { - log.Trace("Incoming call to: " + ctx.Req.Request.URL.String()) + log.Trace("Incoming call to: " + ctx.Req.Request.URL.String()) - fullURL := setting.AppURL + ctx.Req.Request.URL.String()[1:] - log.Trace("Full URL: " + fullURL) + fullURL := setting.AppURL + ctx.Req.Request.URL.String()[1:] + log.Trace("Full URL: " + fullURL) oids, err := models.GetUserOpenIDs(ctx.User.ID) if err != nil { @@ -117,10 +115,10 @@ func settingsOpenIDVerify(ctx *context.Context) { log.Trace("Verified ID: " + id) - oid := &models.UserOpenID{UID:ctx.User.ID, URI:id} + oid := &models.UserOpenID{UID: ctx.User.ID, URI: id} if err = models.AddUserOpenID(oid); err != nil { if models.IsErrOpenIDAlreadyUsed(err) { - ctx.RenderWithErr(ctx.Tr("form.openid_been_used", id), tplSettingsOpenID, &auth.AddOpenIDForm{ Openid: id }) + ctx.RenderWithErr(ctx.Tr("form.openid_been_used", id), tplSettingsOpenID, &auth.AddOpenIDForm{Openid: id}) return } ctx.Handle(500, "AddUserOpenID", err) @@ -155,4 +153,3 @@ func ToggleOpenIDVisibility(ctx *context.Context) { ctx.Redirect(setting.AppSubURL + "/user/settings/openid") } - |