diff --git a/authz/authz.go b/authz/authz.go index 3287dac9..9e89d32a 100644 --- a/authz/authz.go +++ b/authz/authz.go @@ -90,6 +90,7 @@ p, *, *, POST, /api/set-password, *, * p, *, *, POST, /api/send-verification-code, *, * p, *, *, GET, /api/get-human-check, *, * p, *, *, POST, /api/reset-email-or-phone, *, * +p, *, *, POST, /api/upload-resource, *, * ` sa := stringadapter.NewAdapter(ruleText) diff --git a/controllers/account.go b/controllers/account.go index 253a9353..d433151e 100644 --- a/controllers/account.go +++ b/controllers/account.go @@ -148,6 +148,7 @@ func (c *ApiController) Signup() { Address: []string{}, Affiliation: form.Affiliation, Region: form.Region, + Score: getInitScore(), IsAdmin: false, IsGlobalAdmin: false, IsForbidden: false, diff --git a/controllers/auth.go b/controllers/auth.go index cbfa19d2..65afbe2e 100644 --- a/controllers/auth.go +++ b/controllers/auth.go @@ -277,12 +277,6 @@ func (c *ApiController) Login() { return } - var score int - score, err = strconv.Atoi(beego.AppConfig.String("initScore")) - if err != nil { - panic(err) - } - properties := map[string]string{} properties["no"] = strconv.Itoa(len(object.GetUsers(application.Organization)) + 2) user := &object.User{ @@ -295,7 +289,7 @@ func (c *ApiController) Login() { Avatar: userInfo.AvatarUrl, Address: []string{}, Email: userInfo.Email, - Score: score, + Score: getInitScore(), IsAdmin: false, IsGlobalAdmin: false, IsForbidden: false, diff --git a/controllers/util.go b/controllers/util.go index dc472533..7b2b03a3 100644 --- a/controllers/util.go +++ b/controllers/util.go @@ -14,6 +14,12 @@ package controllers +import ( + "strconv" + + "github.com/astaxie/beego" +) + // ResponseOk ... func (c *ApiController) ResponseOk(data ...interface{}) { resp := Response{Status: "ok"} @@ -51,3 +57,12 @@ func (c *ApiController) RequireSignedIn() (string, bool) { } return userId, true } + +func getInitScore() int { + score, err := strconv.Atoi(beego.AppConfig.String("initScore")) + if err != nil { + panic(err) + } + + return score +} diff --git a/object/init.go b/object/init.go index b1350d55..0b75cd23 100644 --- a/object/init.go +++ b/object/init.go @@ -63,6 +63,7 @@ func initBuiltInUser() { Address: []string{}, Affiliation: "Example Inc.", Tag: "staff", + Score: 2000, IsAdmin: true, IsGlobalAdmin: true, IsForbidden: false, diff --git a/object/ldap.go b/object/ldap.go index 0e4179c2..e3ce3279 100644 --- a/object/ldap.go +++ b/object/ldap.go @@ -305,6 +305,7 @@ func SyncLdapUsers(owner string, users []LdapRespUser) (*[]LdapRespUser, *[]Ldap Address: []string{user.Address}, Affiliation: "Example Inc.", Tag: "staff", + Score: 2000, Ldap: user.Uuid, }) { failedUsers = append(failedUsers, user)