Run "make fmt" with go-1.6 (#1333)
This commit is contained in:
parent
888dee3b5f
commit
f73e734411
|
@ -12,9 +12,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var signupFormSample map[string][]string = map[string][]string{
|
var signupFormSample map[string][]string = map[string][]string{
|
||||||
"Name": []string{"tester"},
|
"Name": {"tester"},
|
||||||
"Email": []string{"user1@example.com"},
|
"Email": {"user1@example.com"},
|
||||||
"Passwd": []string{"12345678"},
|
"Passwd": {"12345678"},
|
||||||
}
|
}
|
||||||
|
|
||||||
func signup(t *utils.T) error {
|
func signup(t *utils.T) error {
|
||||||
|
|
|
@ -68,7 +68,9 @@ func TestGetParticipantsByIssueID(t *testing.T) {
|
||||||
partecipants, err := GetParticipantsByIssueID(issueID)
|
partecipants, err := GetParticipantsByIssueID(issueID)
|
||||||
if assert.NoError(t, err) {
|
if assert.NoError(t, err) {
|
||||||
partecipantsIDs := make([]int, len(partecipants))
|
partecipantsIDs := make([]int, len(partecipants))
|
||||||
for i,u := range partecipants { partecipantsIDs[i] = int(u.ID) }
|
for i, u := range partecipants {
|
||||||
|
partecipantsIDs[i] = int(u.ID)
|
||||||
|
}
|
||||||
sort.Ints(partecipantsIDs)
|
sort.Ints(partecipantsIDs)
|
||||||
sort.Ints(userIDs)
|
sort.Ints(userIDs)
|
||||||
assert.Equal(t, userIDs, partecipantsIDs)
|
assert.Equal(t, userIDs, partecipantsIDs)
|
||||||
|
|
|
@ -17,7 +17,6 @@ type UserOpenID struct {
|
||||||
URI string `xorm:"UNIQUE NOT NULL"`
|
URI string `xorm:"UNIQUE NOT NULL"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func addUserOpenID(x *xorm.Engine) error {
|
func addUserOpenID(x *xorm.Engine) error {
|
||||||
if err := x.Sync2(new(UserOpenID)); err != nil {
|
if err := x.Sync2(new(UserOpenID)); err != nil {
|
||||||
return fmt.Errorf("Sync2: %v", err)
|
return fmt.Errorf("Sync2: %v", err)
|
||||||
|
|
|
@ -68,4 +68,3 @@ func UnfollowUser(userID, followID int64) (err error) {
|
||||||
}
|
}
|
||||||
return sess.Commit()
|
return sess.Commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,4 +122,3 @@ func GetUserByOpenID(uri string) (*User, error) {
|
||||||
|
|
||||||
return nil, ErrUserNotExist{0, uri, 0}
|
return nil, ErrUserNotExist{0, uri, 0}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,4 +56,3 @@ func (s *timedDiscoveryCache) Get(id string) openid.DiscoveredInfo {
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type testDiscoveredInfo struct{}
|
type testDiscoveredInfo struct{}
|
||||||
|
|
||||||
func (s *testDiscoveredInfo) ClaimedID() string {
|
func (s *testDiscoveredInfo) ClaimedID() string {
|
||||||
return "claimedID"
|
return "claimedID"
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@ import (
|
||||||
var nonceStore = openid.NewSimpleNonceStore()
|
var nonceStore = openid.NewSimpleNonceStore()
|
||||||
var discoveryCache = newTimedDiscoveryCache(24 * time.Hour)
|
var discoveryCache = newTimedDiscoveryCache(24 * time.Hour)
|
||||||
|
|
||||||
|
|
||||||
// Verify handles response from OpenID provider
|
// Verify handles response from OpenID provider
|
||||||
func Verify(fullURL string) (id string, err error) {
|
func Verify(fullURL string) (id string, err error) {
|
||||||
return openid.Verify(fullURL, discoveryCache, nonceStore)
|
return openid.Verify(fullURL, discoveryCache, nonceStore)
|
||||||
|
@ -34,4 +33,3 @@ func Normalize(url string) (id string, err error) {
|
||||||
func RedirectURL(id, callbackURL, realm string) (string, error) {
|
func RedirectURL(id, callbackURL, realm string) (string, error) {
|
||||||
return openid.RedirectURL(id, callbackURL, realm)
|
return openid.RedirectURL(id, callbackURL, realm)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ import (
|
||||||
"gopkg.in/macaron.v1"
|
"gopkg.in/macaron.v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
// SignInOpenIDForm form for signing in with OpenID
|
// SignInOpenIDForm form for signing in with OpenID
|
||||||
type SignInOpenIDForm struct {
|
type SignInOpenIDForm struct {
|
||||||
Openid string `binding:"Required;MaxSize(256)"`
|
Openid string `binding:"Required;MaxSize(256)"`
|
||||||
|
@ -42,4 +41,3 @@ type ConnectOpenIDForm struct {
|
||||||
func (f *ConnectOpenIDForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
func (f *ConnectOpenIDForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
||||||
return validate(errs, ctx.Data, f, ctx.Locale)
|
return validate(errs, ctx.Data, f, ctx.Locale)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -762,14 +762,14 @@ please consider changing to GITEA_CUSTOM`)
|
||||||
EnableOpenIDSignIn = sec.Key("ENABLE_OPENID_SIGNIN").MustBool(true)
|
EnableOpenIDSignIn = sec.Key("ENABLE_OPENID_SIGNIN").MustBool(true)
|
||||||
EnableOpenIDSignUp = sec.Key("ENABLE_OPENID_SIGNUP").MustBool(true)
|
EnableOpenIDSignUp = sec.Key("ENABLE_OPENID_SIGNUP").MustBool(true)
|
||||||
pats := sec.Key("WHITELISTED_URIS").Strings(" ")
|
pats := sec.Key("WHITELISTED_URIS").Strings(" ")
|
||||||
if ( len(pats) != 0 ) {
|
if len(pats) != 0 {
|
||||||
OpenIDWhitelist = make([]*regexp.Regexp, len(pats))
|
OpenIDWhitelist = make([]*regexp.Regexp, len(pats))
|
||||||
for i, p := range pats {
|
for i, p := range pats {
|
||||||
OpenIDWhitelist[i] = regexp.MustCompilePOSIX(p)
|
OpenIDWhitelist[i] = regexp.MustCompilePOSIX(p)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pats = sec.Key("BLACKLISTED_URIS").Strings(" ")
|
pats = sec.Key("BLACKLISTED_URIS").Strings(" ")
|
||||||
if ( len(pats) != 0 ) {
|
if len(pats) != 0 {
|
||||||
OpenIDBlacklist = make([]*regexp.Regexp, len(pats))
|
OpenIDBlacklist = make([]*regexp.Regexp, len(pats))
|
||||||
for i, p := range pats {
|
for i, p := range pats {
|
||||||
OpenIDBlacklist[i] = regexp.MustCompilePOSIX(p)
|
OpenIDBlacklist[i] = regexp.MustCompilePOSIX(p)
|
||||||
|
|
|
@ -102,22 +102,23 @@ func SignInOpenIDPost(ctx *context.Context, form auth.SignInOpenIDForm) {
|
||||||
id, err := openid.Normalize(form.Openid)
|
id, err := openid.Normalize(form.Openid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.RenderWithErr(err.Error(), tplSignInOpenID, &form)
|
ctx.RenderWithErr(err.Error(), tplSignInOpenID, &form)
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
form.Openid = id
|
form.Openid = id
|
||||||
|
|
||||||
log.Trace("OpenID uri: " + id)
|
log.Trace("OpenID uri: " + id)
|
||||||
|
|
||||||
err = allowedOpenIDURI(id); if err != nil {
|
err = allowedOpenIDURI(id)
|
||||||
|
if err != nil {
|
||||||
ctx.RenderWithErr(err.Error(), tplSignInOpenID, &form)
|
ctx.RenderWithErr(err.Error(), tplSignInOpenID, &form)
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
redirectTo := setting.AppURL + "user/login/openid"
|
redirectTo := setting.AppURL + "user/login/openid"
|
||||||
url, err := openid.RedirectURL(id, redirectTo, setting.AppURL)
|
url, err := openid.RedirectURL(id, redirectTo, setting.AppURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.RenderWithErr(err.Error(), tplSignInOpenID, &form)
|
ctx.RenderWithErr(err.Error(), tplSignInOpenID, &form)
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Request optional nickname and email info
|
// Request optional nickname and email info
|
||||||
|
@ -351,7 +352,9 @@ func RegisterOpenIDPost(ctx *context.Context, cpt *captcha.Captcha, form auth.Si
|
||||||
}
|
}
|
||||||
|
|
||||||
len := setting.MinPasswordLength
|
len := setting.MinPasswordLength
|
||||||
if len < 256 { len = 256 }
|
if len < 256 {
|
||||||
|
len = 256
|
||||||
|
}
|
||||||
password, err := base.GetRandomString(len)
|
password, err := base.GetRandomString(len)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.RenderWithErr(err.Error(), tplSignUpOID, form)
|
ctx.RenderWithErr(err.Error(), tplSignUpOID, form)
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
package user
|
package user
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
||||||
"code.gitea.io/gitea/models"
|
"code.gitea.io/gitea/models"
|
||||||
"code.gitea.io/gitea/modules/auth"
|
"code.gitea.io/gitea/modules/auth"
|
||||||
"code.gitea.io/gitea/modules/auth/openid"
|
"code.gitea.io/gitea/modules/auth/openid"
|
||||||
|
@ -64,7 +63,7 @@ func SettingsOpenIDPost(ctx *context.Context, form auth.AddOpenIDForm) {
|
||||||
id, err := openid.Normalize(form.Openid)
|
id, err := openid.Normalize(form.Openid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.RenderWithErr(err.Error(), tplSettingsOpenID, &form)
|
ctx.RenderWithErr(err.Error(), tplSettingsOpenID, &form)
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
form.Openid = id
|
form.Openid = id
|
||||||
log.Trace("Normalized id: " + id)
|
log.Trace("Normalized id: " + id)
|
||||||
|
@ -84,12 +83,11 @@ func SettingsOpenIDPost(ctx *context.Context, form auth.AddOpenIDForm) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
redirectTo := setting.AppURL + "user/settings/openid"
|
redirectTo := setting.AppURL + "user/settings/openid"
|
||||||
url, err := openid.RedirectURL(id, redirectTo, setting.AppURL)
|
url, err := openid.RedirectURL(id, redirectTo, setting.AppURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.RenderWithErr(err.Error(), tplSettingsOpenID, &form)
|
ctx.RenderWithErr(err.Error(), tplSettingsOpenID, &form)
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
ctx.Redirect(url)
|
ctx.Redirect(url)
|
||||||
}
|
}
|
||||||
|
@ -155,4 +153,3 @@ func ToggleOpenIDVisibility(ctx *context.Context) {
|
||||||
|
|
||||||
ctx.Redirect(setting.AppSubURL + "/user/settings/openid")
|
ctx.Redirect(setting.AppSubURL + "/user/settings/openid")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue