mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Run "make fmt" with go-1.6 (#1333)
This commit is contained in:
committed by
Lunny Xiao
parent
888dee3b5f
commit
f73e734411
@@ -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)
|
||||
|
@@ -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")
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user