mirror of
https://github.com/go-gitea/gitea
synced 2024-12-22 02:37:54 +01:00
Merge branch 'develop' of github.com:gogits/gogs into feature/milestone
# Conflicts: # gogs.go # models/issue.go # templates/.VERSION
This commit is contained in:
commit
2c507667bf
@ -24,7 +24,9 @@ github.com/macaron-contrib/oauth2 = commit:8f394c3629
|
|||||||
github.com/macaron-contrib/session = commit:e48134e803
|
github.com/macaron-contrib/session = commit:e48134e803
|
||||||
github.com/macaron-contrib/toolbox = commit:acbfe36e16
|
github.com/macaron-contrib/toolbox = commit:acbfe36e16
|
||||||
github.com/mattn/go-sqlite3 = commit:e28cd440fa
|
github.com/mattn/go-sqlite3 = commit:e28cd440fa
|
||||||
|
github.com/mcuadros/go-version
|
||||||
github.com/microcosm-cc/bluemonday = commit:2b7763a06c
|
github.com/microcosm-cc/bluemonday = commit:2b7763a06c
|
||||||
|
github.com/mssola/user_agent = commit:f659b98638
|
||||||
github.com/msteinert/pam = commit:9a42d39dbf
|
github.com/msteinert/pam = commit:9a42d39dbf
|
||||||
github.com/nfnt/resize = commit:dc93e1b98c
|
github.com/nfnt/resize = commit:dc93e1b98c
|
||||||
github.com/russross/blackfriday = commit:8cec3a854e
|
github.com/russross/blackfriday = commit:8cec3a854e
|
||||||
|
94
cmd/serve.go
94
cmd/serve.go
@ -78,35 +78,18 @@ func runServ(c *cli.Context) {
|
|||||||
setup("serv.log")
|
setup("serv.log")
|
||||||
|
|
||||||
fail := func(userMessage, logMessage string, args ...interface{}) {
|
fail := func(userMessage, logMessage string, args ...interface{}) {
|
||||||
fmt.Fprintln(os.Stderr, "Gogs: ", userMessage)
|
fmt.Fprintln(os.Stderr, "Gogs:", userMessage)
|
||||||
log.GitLogger.Fatal(2, logMessage, args...)
|
log.GitLogger.Fatal(3, logMessage, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(c.Args()) < 1 {
|
if len(c.Args()) < 1 {
|
||||||
fail("Not enough arguments", "Not enough arguments")
|
fail("Not enough arguments", "Not enough arguments")
|
||||||
}
|
}
|
||||||
|
|
||||||
keys := strings.Split(c.Args()[0], "-")
|
|
||||||
if len(keys) != 2 {
|
|
||||||
fail("key-id format error", "Invalid key id: %s", c.Args()[0])
|
|
||||||
}
|
|
||||||
|
|
||||||
keyId, err := com.StrTo(keys[1]).Int64()
|
|
||||||
if err != nil {
|
|
||||||
fail("key-id format error", "Invalid key id: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
user, err := models.GetUserByKeyId(keyId)
|
|
||||||
if err != nil {
|
|
||||||
fail("internal error", "Failed to get user by key ID(%d): %v", keyId, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd := os.Getenv("SSH_ORIGINAL_COMMAND")
|
cmd := os.Getenv("SSH_ORIGINAL_COMMAND")
|
||||||
if cmd == "" {
|
if len(cmd) == 0 {
|
||||||
fmt.Printf("Hi, %s! You've successfully authenticated, but Gogs does not provide shell access.\n", user.Name)
|
println("Hi there, You've successfully authenticated, but Gogs does not provide shell access.")
|
||||||
if user.IsAdmin {
|
println("If this is unexpected, please log in with password and setup Gogs under another user.")
|
||||||
println("If this is unexpected, please log in with password and setup Gogs under another user.")
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,7 +104,7 @@ func runServ(c *cli.Context) {
|
|||||||
|
|
||||||
repoUser, err := models.GetUserByName(repoUserName)
|
repoUser, err := models.GetUserByName(repoUserName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == models.ErrUserNotExist {
|
if models.IsErrUserNotExist(err) {
|
||||||
fail("Repository owner does not exist", "Unregistered owner: %s", repoUserName)
|
fail("Repository owner does not exist", "Unregistered owner: %s", repoUserName)
|
||||||
}
|
}
|
||||||
fail("Internal error", "Failed to get repository owner(%s): %v", repoUserName, err)
|
fail("Internal error", "Failed to get repository owner(%s): %v", repoUserName, err)
|
||||||
@ -130,11 +113,7 @@ func runServ(c *cli.Context) {
|
|||||||
repo, err := models.GetRepositoryByName(repoUser.Id, repoName)
|
repo, err := models.GetRepositoryByName(repoUser.Id, repoName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrRepoNotExist(err) {
|
if models.IsErrRepoNotExist(err) {
|
||||||
if user.Id == repoUser.Id || repoUser.IsOwnedBy(user.Id) {
|
fail(_ACCESS_DENIED_MESSAGE, "Repository does not exist: %s/%s", repoUser.Name, repoName)
|
||||||
fail("Repository does not exist", "Repository does not exist: %s/%s", repoUser.Name, repoName)
|
|
||||||
} else {
|
|
||||||
fail(_ACCESS_DENIED_MESSAGE, "Repository does not exist: %s/%s", repoUser.Name, repoName)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
fail("Internal error", "Failed to get repository: %v", err)
|
fail("Internal error", "Failed to get repository: %v", err)
|
||||||
}
|
}
|
||||||
@ -144,17 +123,39 @@ func runServ(c *cli.Context) {
|
|||||||
fail("Unknown git command", "Unknown git command %s", verb)
|
fail("Unknown git command", "Unknown git command %s", verb)
|
||||||
}
|
}
|
||||||
|
|
||||||
mode, err := models.AccessLevel(user, repo)
|
// Allow anonymous clone for public repositories.
|
||||||
if err != nil {
|
var (
|
||||||
fail("Internal error", "Fail to check access: %v", err)
|
keyID int64
|
||||||
} else if mode < requestedMode {
|
user *models.User
|
||||||
clientMessage := _ACCESS_DENIED_MESSAGE
|
)
|
||||||
if mode >= models.ACCESS_MODE_READ {
|
if requestedMode == models.ACCESS_MODE_WRITE || repo.IsPrivate {
|
||||||
clientMessage = "You do not have sufficient authorization for this action"
|
keys := strings.Split(c.Args()[0], "-")
|
||||||
|
if len(keys) != 2 {
|
||||||
|
fail("key-id format error", "Invalid key id: %s", c.Args()[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
keyID, err = com.StrTo(keys[1]).Int64()
|
||||||
|
if err != nil {
|
||||||
|
fail("key-id format error", "Invalid key id: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
user, err = models.GetUserByKeyId(keyID)
|
||||||
|
if err != nil {
|
||||||
|
fail("internal error", "Failed to get user by key ID(%d): %v", keyID, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
mode, err := models.AccessLevel(user, repo)
|
||||||
|
if err != nil {
|
||||||
|
fail("Internal error", "Fail to check access: %v", err)
|
||||||
|
} else if mode < requestedMode {
|
||||||
|
clientMessage := _ACCESS_DENIED_MESSAGE
|
||||||
|
if mode >= models.ACCESS_MODE_READ {
|
||||||
|
clientMessage = "You do not have sufficient authorization for this action"
|
||||||
|
}
|
||||||
|
fail(clientMessage,
|
||||||
|
"User %s does not have level %v access to repository %s",
|
||||||
|
user.Name, requestedMode, repoPath)
|
||||||
}
|
}
|
||||||
fail(clientMessage,
|
|
||||||
"User %s does not have level %v access to repository %s",
|
|
||||||
user.Name, requestedMode, repoPath)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uuid := uuid.NewV4().String()
|
uuid := uuid.NewV4().String()
|
||||||
@ -201,12 +202,15 @@ func runServ(c *cli.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update key activity.
|
// Update key activity.
|
||||||
key, err := models.GetPublicKeyById(keyId)
|
if keyID > 0 {
|
||||||
if err != nil {
|
key, err := models.GetPublicKeyById(keyID)
|
||||||
fail("Internal error", "GetPublicKeyById: %v", err)
|
if err != nil {
|
||||||
}
|
fail("Internal error", "GetPublicKeyById: %v", err)
|
||||||
key.Updated = time.Now()
|
}
|
||||||
if err = models.UpdatePublicKey(key); err != nil {
|
|
||||||
fail("Internal error", "UpdatePublicKey: %v", err)
|
key.Updated = time.Now()
|
||||||
|
if err = models.UpdatePublicKey(key); err != nil {
|
||||||
|
fail("Internal error", "UpdatePublicKey: %v", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -493,17 +493,6 @@
|
|||||||
"outputPathIsOutsideProject": 0,
|
"outputPathIsOutsideProject": 0,
|
||||||
"outputPathIsSetByUser": 0
|
"outputPathIsSetByUser": 0
|
||||||
},
|
},
|
||||||
"\/public\/ng\/js\/gogs.js": {
|
|
||||||
"fileType": 64,
|
|
||||||
"ignore": 0,
|
|
||||||
"ignoreWasSetByUser": 0,
|
|
||||||
"inputAbbreviatedPath": "\/public\/ng\/js\/gogs.js",
|
|
||||||
"outputAbbreviatedPath": "\/public\/ng\/js\/min\/gogs-min.js",
|
|
||||||
"outputPathIsOutsideProject": 0,
|
|
||||||
"outputPathIsSetByUser": 0,
|
|
||||||
"outputStyle": 1,
|
|
||||||
"syntaxCheckerStyle": 1
|
|
||||||
},
|
|
||||||
"\/public\/ng\/js\/gogs\/issue_label.js": {
|
"\/public\/ng\/js\/gogs\/issue_label.js": {
|
||||||
"fileType": 64,
|
"fileType": 64,
|
||||||
"ignore": 1,
|
"ignore": 1,
|
||||||
|
@ -54,6 +54,20 @@ func (err ErrUserAlreadyExist) Error() string {
|
|||||||
return fmt.Sprintf("user already exists: [name: %s]", err.Name)
|
return fmt.Sprintf("user already exists: [name: %s]", err.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ErrUserNotExist struct {
|
||||||
|
UID int64
|
||||||
|
Name string
|
||||||
|
}
|
||||||
|
|
||||||
|
func IsErrUserNotExist(err error) bool {
|
||||||
|
_, ok := err.(ErrUserNotExist)
|
||||||
|
return ok
|
||||||
|
}
|
||||||
|
|
||||||
|
func (err ErrUserNotExist) Error() string {
|
||||||
|
return fmt.Sprintf("user does not exist: [uid: %d, name: %s]", err.UID, err.Name)
|
||||||
|
}
|
||||||
|
|
||||||
type ErrEmailAlreadyUsed struct {
|
type ErrEmailAlreadyUsed struct {
|
||||||
Email string
|
Email string
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ func (i *Issue) BeforeSet(colName string, val xorm.Cell) {
|
|||||||
|
|
||||||
func (i *Issue) GetPoster() (err error) {
|
func (i *Issue) GetPoster() (err error) {
|
||||||
i.Poster, err = GetUserById(i.PosterID)
|
i.Poster, err = GetUserById(i.PosterID)
|
||||||
if err == ErrUserNotExist {
|
if IsErrUserNotExist(err) {
|
||||||
i.Poster = &User{Name: "FakeUser"}
|
i.Poster = &User{Name: "FakeUser"}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -108,8 +108,9 @@ func (i *Issue) GetAssignee() (err error) {
|
|||||||
if i.AssigneeID == 0 {
|
if i.AssigneeID == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
i.Assignee, err = GetUserById(i.AssigneeID)
|
i.Assignee, err = GetUserById(i.AssigneeID)
|
||||||
if err == ErrUserNotExist {
|
if IsErrUserNotExist(err) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
@ -41,7 +41,7 @@ var (
|
|||||||
var LoginTypes = map[LoginType]string{
|
var LoginTypes = map[LoginType]string{
|
||||||
LDAP: "LDAP",
|
LDAP: "LDAP",
|
||||||
SMTP: "SMTP",
|
SMTP: "SMTP",
|
||||||
PAM: "PAM",
|
PAM: "PAM",
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure structs implemented interface.
|
// Ensure structs implemented interface.
|
||||||
@ -192,7 +192,7 @@ func UserSignIn(uname, passwd string) (*User, error) {
|
|||||||
// Now verify password.
|
// Now verify password.
|
||||||
if u.LoginType == PLAIN {
|
if u.LoginType == PLAIN {
|
||||||
if !u.ValidatePassword(passwd) {
|
if !u.ValidatePassword(passwd) {
|
||||||
return nil, ErrUserNotExist
|
return nil, ErrUserNotExist{u.Id, u.Name}
|
||||||
}
|
}
|
||||||
return u, nil
|
return u, nil
|
||||||
}
|
}
|
||||||
@ -229,7 +229,7 @@ func UserSignIn(uname, passwd string) (*User, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, ErrUserNotExist
|
return nil, ErrUserNotExist{u.Id, u.Name}
|
||||||
}
|
}
|
||||||
|
|
||||||
var source LoginSource
|
var source LoginSource
|
||||||
@ -261,7 +261,7 @@ func LoginUserLdapSource(u *User, name, passwd string, sourceId int64, cfg *LDAP
|
|||||||
name, fn, sn, mail, logged := cfg.Ldapsource.SearchEntry(name, passwd)
|
name, fn, sn, mail, logged := cfg.Ldapsource.SearchEntry(name, passwd)
|
||||||
if !logged {
|
if !logged {
|
||||||
// User not in LDAP, do nothing
|
// User not in LDAP, do nothing
|
||||||
return nil, ErrUserNotExist
|
return nil, ErrUserNotExist{u.Id, u.Name}
|
||||||
}
|
}
|
||||||
if !autoRegister {
|
if !autoRegister {
|
||||||
return u, nil
|
return u, nil
|
||||||
@ -362,7 +362,7 @@ func LoginUserSMTPSource(u *User, name, passwd string, sourceId int64, cfg *SMTP
|
|||||||
|
|
||||||
if err := SmtpAuth(cfg.Host, cfg.Port, auth, cfg.TLS); err != nil {
|
if err := SmtpAuth(cfg.Host, cfg.Port, auth, cfg.TLS); err != nil {
|
||||||
if strings.Contains(err.Error(), "Username and Password not accepted") {
|
if strings.Contains(err.Error(), "Username and Password not accepted") {
|
||||||
return nil, ErrUserNotExist
|
return nil, ErrUserNotExist{u.Id, u.Name}
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -397,7 +397,7 @@ func LoginUserSMTPSource(u *User, name, passwd string, sourceId int64, cfg *SMTP
|
|||||||
func LoginUserPAMSource(u *User, name, passwd string, sourceId int64, cfg *PAMConfig, autoRegister bool) (*User, error) {
|
func LoginUserPAMSource(u *User, name, passwd string, sourceId int64, cfg *PAMConfig, autoRegister bool) (*User, error) {
|
||||||
if err := pam.PAMAuth(cfg.ServiceName, name, passwd); err != nil {
|
if err := pam.PAMAuth(cfg.ServiceName, name, passwd); err != nil {
|
||||||
if strings.Contains(err.Error(), "Authentication failure") {
|
if strings.Contains(err.Error(), "Authentication failure") {
|
||||||
return nil, ErrUserNotExist
|
return nil, ErrUserNotExist{u.Id, u.Name}
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -624,7 +624,7 @@ func GetRepositoriesWithUsers(num, offset int) ([]*Repository, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if !has {
|
} else if !has {
|
||||||
return nil, ErrUserNotExist
|
return nil, ErrUserNotExist{repo.OwnerId, ""}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,6 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ErrUserNotExist = errors.New("User does not exist")
|
|
||||||
ErrUserNotKeyOwner = errors.New("User does not the owner of public key")
|
ErrUserNotKeyOwner = errors.New("User does not the owner of public key")
|
||||||
ErrEmailNotExist = errors.New("E-mail does not exist")
|
ErrEmailNotExist = errors.New("E-mail does not exist")
|
||||||
ErrEmailNotActivated = errors.New("E-mail address has not been activated")
|
ErrEmailNotActivated = errors.New("E-mail address has not been activated")
|
||||||
@ -259,6 +258,8 @@ func IsEmailUsed(email string) (bool, error) {
|
|||||||
if len(email) == 0 {
|
if len(email) == 0 {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
email = strings.ToLower(email)
|
||||||
if has, err := x.Get(&EmailAddress{Email: email}); has || err != nil {
|
if has, err := x.Get(&EmailAddress{Email: email}); has || err != nil {
|
||||||
return has, err
|
return has, err
|
||||||
}
|
}
|
||||||
@ -406,6 +407,7 @@ func ChangeUserName(u *User, newUserName string) (err error) {
|
|||||||
|
|
||||||
// UpdateUser updates user's information.
|
// UpdateUser updates user's information.
|
||||||
func UpdateUser(u *User) error {
|
func UpdateUser(u *User) error {
|
||||||
|
u.Email = strings.ToLower(u.Email)
|
||||||
has, err := x.Where("id!=?", u.Id).And("type=?", u.Type).And("email=?", u.Email).Get(new(User))
|
has, err := x.Where("id!=?", u.Id).And("type=?", u.Type).And("email=?", u.Email).Get(new(User))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -555,7 +557,7 @@ func getUserById(e Engine, id int64) (*User, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if !has {
|
} else if !has {
|
||||||
return nil, ErrUserNotExist
|
return nil, ErrUserNotExist{id, ""}
|
||||||
}
|
}
|
||||||
return u, nil
|
return u, nil
|
||||||
}
|
}
|
||||||
@ -568,14 +570,14 @@ func GetUserById(id int64) (*User, error) {
|
|||||||
// GetUserByName returns user by given name.
|
// GetUserByName returns user by given name.
|
||||||
func GetUserByName(name string) (*User, error) {
|
func GetUserByName(name string) (*User, error) {
|
||||||
if len(name) == 0 {
|
if len(name) == 0 {
|
||||||
return nil, ErrUserNotExist
|
return nil, ErrUserNotExist{0, name}
|
||||||
}
|
}
|
||||||
u := &User{LowerName: strings.ToLower(name)}
|
u := &User{LowerName: strings.ToLower(name)}
|
||||||
has, err := x.Get(u)
|
has, err := x.Get(u)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if !has {
|
} else if !has {
|
||||||
return nil, ErrUserNotExist
|
return nil, ErrUserNotExist{0, name}
|
||||||
}
|
}
|
||||||
return u, nil
|
return u, nil
|
||||||
}
|
}
|
||||||
@ -642,6 +644,7 @@ func GetEmailAddresses(uid int64) ([]*EmailAddress, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func AddEmailAddress(email *EmailAddress) error {
|
func AddEmailAddress(email *EmailAddress) error {
|
||||||
|
email.Email = strings.ToLower(email.Email)
|
||||||
used, err := IsEmailUsed(email.Email)
|
used, err := IsEmailUsed(email.Email)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -675,7 +678,7 @@ func DeleteEmailAddress(email *EmailAddress) error {
|
|||||||
return ErrEmailNotExist
|
return ErrEmailNotExist
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err = x.Delete(email); err != nil {
|
if _, err = x.Id(email.Id).Delete(email); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -700,7 +703,7 @@ func MakeEmailPrimary(email *EmailAddress) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
} else if !has {
|
} else if !has {
|
||||||
return ErrUserNotExist
|
return ErrUserNotExist{email.Uid, ""}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the former primary email doesn't disappear
|
// Make sure the former primary email doesn't disappear
|
||||||
@ -737,13 +740,15 @@ func ValidateCommitWithEmail(c *git.Commit) *User {
|
|||||||
|
|
||||||
// ValidateCommitsWithEmails checks if authors' e-mails of commits are corresponding to users.
|
// ValidateCommitsWithEmails checks if authors' e-mails of commits are corresponding to users.
|
||||||
func ValidateCommitsWithEmails(oldCommits *list.List) *list.List {
|
func ValidateCommitsWithEmails(oldCommits *list.List) *list.List {
|
||||||
emails := map[string]*User{}
|
var (
|
||||||
newCommits := list.New()
|
u *User
|
||||||
e := oldCommits.Front()
|
emails = map[string]*User{}
|
||||||
|
newCommits = list.New()
|
||||||
|
e = oldCommits.Front()
|
||||||
|
)
|
||||||
for e != nil {
|
for e != nil {
|
||||||
c := e.Value.(*git.Commit)
|
c := e.Value.(*git.Commit)
|
||||||
|
|
||||||
var u *User
|
|
||||||
if v, ok := emails[c.Author.Email]; !ok {
|
if v, ok := emails[c.Author.Email]; !ok {
|
||||||
u, _ = GetUserByEmail(c.Author.Email)
|
u, _ = GetUserByEmail(c.Author.Email)
|
||||||
emails[c.Author.Email] = u
|
emails[c.Author.Email] = u
|
||||||
@ -763,10 +768,12 @@ func ValidateCommitsWithEmails(oldCommits *list.List) *list.List {
|
|||||||
// GetUserByEmail returns the user object by given e-mail if exists.
|
// GetUserByEmail returns the user object by given e-mail if exists.
|
||||||
func GetUserByEmail(email string) (*User, error) {
|
func GetUserByEmail(email string) (*User, error) {
|
||||||
if len(email) == 0 {
|
if len(email) == 0 {
|
||||||
return nil, ErrUserNotExist
|
return nil, ErrUserNotExist{0, "email"}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
email = strings.ToLower(email)
|
||||||
// First try to find the user by primary email
|
// First try to find the user by primary email
|
||||||
user := &User{Email: strings.ToLower(email)}
|
user := &User{Email: email}
|
||||||
has, err := x.Get(user)
|
has, err := x.Get(user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -776,7 +783,7 @@ func GetUserByEmail(email string) (*User, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, check in alternative list for activated email addresses
|
// Otherwise, check in alternative list for activated email addresses
|
||||||
emailAddress := &EmailAddress{Email: strings.ToLower(email), IsActivated: true}
|
emailAddress := &EmailAddress{Email: email, IsActivated: true}
|
||||||
has, err = x.Get(emailAddress)
|
has, err = x.Get(emailAddress)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -785,7 +792,7 @@ func GetUserByEmail(email string) (*User, error) {
|
|||||||
return GetUserById(emailAddress.Uid)
|
return GetUserById(emailAddress.Uid)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, ErrUserNotExist
|
return nil, ErrUserNotExist{0, "email"}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SearchUserByName returns given number of users whose name contains keyword.
|
// SearchUserByName returns given number of users whose name contains keyword.
|
||||||
|
@ -55,7 +55,7 @@ func SignedInId(req *http.Request, sess session.Store) int64 {
|
|||||||
}
|
}
|
||||||
if id, ok := uid.(int64); ok {
|
if id, ok := uid.(int64); ok {
|
||||||
if _, err := models.GetUserById(id); err != nil {
|
if _, err := models.GetUserById(id); err != nil {
|
||||||
if err != models.ErrUserNotExist {
|
if !models.IsErrUserNotExist(err) {
|
||||||
log.Error(4, "GetUserById: %v", err)
|
log.Error(4, "GetUserById: %v", err)
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
@ -80,7 +80,7 @@ func SignedInUser(req *http.Request, sess session.Store) (*models.User, bool) {
|
|||||||
if len(webAuthUser) > 0 {
|
if len(webAuthUser) > 0 {
|
||||||
u, err := models.GetUserByName(webAuthUser)
|
u, err := models.GetUserByName(webAuthUser)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err != models.ErrUserNotExist {
|
if !models.IsErrUserNotExist(err) {
|
||||||
log.Error(4, "GetUserByName: %v", err)
|
log.Error(4, "GetUserByName: %v", err)
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
@ -115,7 +115,7 @@ func SignedInUser(req *http.Request, sess session.Store) (*models.User, bool) {
|
|||||||
|
|
||||||
u, err := models.UserSignIn(uname, passwd)
|
u, err := models.UserSignIn(uname, passwd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err != models.ErrUserNotExist {
|
if !models.IsErrUserNotExist(err) {
|
||||||
log.Error(4, "UserSignIn: %v", err)
|
log.Error(4, "UserSignIn: %v", err)
|
||||||
}
|
}
|
||||||
return nil, false
|
return nil, false
|
||||||
|
@ -26,7 +26,7 @@ func (f *CreateOrgForm) Validate(ctx *macaron.Context, errs binding.Errors) bind
|
|||||||
}
|
}
|
||||||
|
|
||||||
type UpdateOrgSettingForm struct {
|
type UpdateOrgSettingForm struct {
|
||||||
OrgUserName string `form:"uname" binding:"Required;MaxSize(35)"`
|
OrgUserName string `form:"uname" binding:"Required;AlphaDashDot;MaxSize(30)" locale:"org.org_name_holder"`
|
||||||
OrgFullName string `form:"fullname" binding:"MaxSize(100)"`
|
OrgFullName string `form:"fullname" binding:"MaxSize(100)"`
|
||||||
Email string `form:"email" binding:"Required;Email;MaxSize(50)"`
|
Email string `form:"email" binding:"Required;Email;MaxSize(50)"`
|
||||||
Description string `form:"desc" binding:"MaxSize(255)"`
|
Description string `form:"desc" binding:"MaxSize(255)"`
|
||||||
|
@ -34,7 +34,7 @@ func OrgAssignment(redirect bool, args ...bool) macaron.Handler {
|
|||||||
var err error
|
var err error
|
||||||
ctx.Org.Organization, err = models.GetUserByName(orgName)
|
ctx.Org.Organization, err = models.GetUserByName(orgName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == models.ErrUserNotExist {
|
if models.IsErrUserNotExist(err) {
|
||||||
ctx.Handle(404, "GetUserByName", err)
|
ctx.Handle(404, "GetUserByName", err)
|
||||||
} else if redirect {
|
} else if redirect {
|
||||||
log.Error(4, "GetUserByName", err)
|
log.Error(4, "GetUserByName", err)
|
||||||
|
@ -10,6 +10,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/Unknwon/macaron"
|
"github.com/Unknwon/macaron"
|
||||||
|
"github.com/mcuadros/go-version"
|
||||||
|
"github.com/mssola/user_agent"
|
||||||
|
|
||||||
"github.com/gogits/gogs/models"
|
"github.com/gogits/gogs/models"
|
||||||
"github.com/gogits/gogs/modules/base"
|
"github.com/gogits/gogs/modules/base"
|
||||||
@ -18,6 +20,11 @@ import (
|
|||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
FIREFOX_COPY_SUPPORT = "41.0"
|
||||||
|
CHROME_COPY_SUPPORT = "43.0.2356"
|
||||||
|
)
|
||||||
|
|
||||||
func ApiRepoAssignment() macaron.Handler {
|
func ApiRepoAssignment() macaron.Handler {
|
||||||
return func(ctx *Context) {
|
return func(ctx *Context) {
|
||||||
userName := ctx.Params(":username")
|
userName := ctx.Params(":username")
|
||||||
@ -34,7 +41,7 @@ func ApiRepoAssignment() macaron.Handler {
|
|||||||
} else {
|
} else {
|
||||||
u, err = models.GetUserByName(userName)
|
u, err = models.GetUserByName(userName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == models.ErrUserNotExist {
|
if models.IsErrUserNotExist(err) {
|
||||||
ctx.Error(404)
|
ctx.Error(404)
|
||||||
} else {
|
} else {
|
||||||
ctx.JSON(500, &base.ApiJsonErr{"GetUserByName: " + err.Error(), base.DOC_URL})
|
ctx.JSON(500, &base.ApiJsonErr{"GetUserByName: " + err.Error(), base.DOC_URL})
|
||||||
@ -210,7 +217,7 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler {
|
|||||||
} else {
|
} else {
|
||||||
u, err = models.GetUserByName(userName)
|
u, err = models.GetUserByName(userName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == models.ErrUserNotExist {
|
if models.IsErrUserNotExist(err) {
|
||||||
ctx.Handle(404, "GetUserByName", err)
|
ctx.Handle(404, "GetUserByName", err)
|
||||||
} else {
|
} else {
|
||||||
ctx.Handle(500, "GetUserByName", err)
|
ctx.Handle(500, "GetUserByName", err)
|
||||||
@ -345,6 +352,13 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler {
|
|||||||
|
|
||||||
ctx.Data["BranchName"] = ctx.Repo.BranchName
|
ctx.Data["BranchName"] = ctx.Repo.BranchName
|
||||||
ctx.Data["CommitId"] = ctx.Repo.CommitId
|
ctx.Data["CommitId"] = ctx.Repo.CommitId
|
||||||
|
|
||||||
|
userAgent := ctx.Req.Header.Get("User-Agent")
|
||||||
|
ua := user_agent.New(userAgent)
|
||||||
|
browserName, browserVer := ua.Browser()
|
||||||
|
|
||||||
|
ctx.Data["BrowserSupportsCopy"] = (browserName == "Chrome" && version.Compare(browserVer, CHROME_COPY_SUPPORT, ">=")) ||
|
||||||
|
(browserName == "Firefox" && version.Compare(browserVer, FIREFOX_COPY_SUPPORT, ">="))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,36 +269,62 @@ var Gogits = {};
|
|||||||
if ($(selector).hasClass('js-copy-bind')) {
|
if ($(selector).hasClass('js-copy-bind')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$(selector).zclip({
|
|
||||||
path: "/js/ZeroClipboard.swf",
|
if ( document.documentElement.classList.contains("is-copy-enabled") ) {
|
||||||
copy: function () {
|
|
||||||
var t = $(this).data("copy-val");
|
$(selector).click(function(event) {
|
||||||
var to = $($(this).data("copy-from"));
|
|
||||||
var str = "";
|
|
||||||
if (t == "txt") {
|
|
||||||
str = to.text();
|
|
||||||
}
|
|
||||||
if (t == 'val') {
|
|
||||||
str = to.val();
|
|
||||||
}
|
|
||||||
if (t == 'html') {
|
|
||||||
str = to.html();
|
|
||||||
}
|
|
||||||
return str;
|
|
||||||
},
|
|
||||||
afterCopy: function () {
|
|
||||||
var $this = $(this);
|
var $this = $(this);
|
||||||
$this.tooltip('hide')
|
|
||||||
.attr('data-original-title', 'Copied OK');
|
var cfrom = $this.attr('data-copy-from');
|
||||||
|
$(cfrom).select();
|
||||||
|
document.execCommand('copy');
|
||||||
|
getSelection().removeAllRanges();
|
||||||
|
|
||||||
|
$this.tipsy("hide").attr('original-title', $this.data('after-title'));
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
$this.tooltip("show");
|
$this.tipsy("show");
|
||||||
}, 200);
|
}, 200);
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
$this.tooltip('hide')
|
$this.tipsy('hide').attr('original-title', $this.data('original-title'));
|
||||||
.attr('data-original-title', 'Copy to Clipboard');
|
}, 2000);
|
||||||
}, 3000);
|
|
||||||
}
|
this.blur();
|
||||||
}).addClass("js-copy-bind");
|
return;
|
||||||
|
});
|
||||||
|
|
||||||
|
$(selector).addClass("js-copy-bind");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
$(selector).zclip({
|
||||||
|
path: Gogits.AppSubUrl + "/js/ZeroClipboard.swf",
|
||||||
|
copy: function () {
|
||||||
|
var t = $(this).data("copy-val");
|
||||||
|
var to = $($(this).data("copy-from"));
|
||||||
|
var str = "";
|
||||||
|
if (t == "txt") {
|
||||||
|
str = to.text();
|
||||||
|
}
|
||||||
|
if (t == 'val') {
|
||||||
|
str = to.val();
|
||||||
|
}
|
||||||
|
if (t == 'html') {
|
||||||
|
str = to.html();
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
},
|
||||||
|
afterCopy: function () {
|
||||||
|
var $this = $(this);
|
||||||
|
$this.tipsy("hide").attr('original-title', $this.data('after-title'));
|
||||||
|
setTimeout(function () {
|
||||||
|
$this.tipsy("show");
|
||||||
|
}, 200);
|
||||||
|
setTimeout(function () {
|
||||||
|
$this.tipsy('hide').attr('original-title', $this.data('original-title'));
|
||||||
|
}, 2000);
|
||||||
|
}
|
||||||
|
}).addClass("js-copy-bind");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// api working
|
// api working
|
||||||
|
@ -333,25 +333,17 @@ var Gogs = {};
|
|||||||
if ($(selector).hasClass('js-copy-bind')) {
|
if ($(selector).hasClass('js-copy-bind')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$(selector).zclip({
|
|
||||||
path: Gogs.AppSubUrl + "/js/ZeroClipboard.swf",
|
if ( document.documentElement.classList.contains("is-copy-enabled") ) {
|
||||||
copy: function () {
|
|
||||||
var t = $(this).data("copy-val");
|
$(selector).click(function(event) {
|
||||||
var to = $($(this).data("copy-from"));
|
|
||||||
var str = "";
|
|
||||||
if (t == "txt") {
|
|
||||||
str = to.text();
|
|
||||||
}
|
|
||||||
if (t == 'val') {
|
|
||||||
str = to.val();
|
|
||||||
}
|
|
||||||
if (t == 'html') {
|
|
||||||
str = to.html();
|
|
||||||
}
|
|
||||||
return str;
|
|
||||||
},
|
|
||||||
afterCopy: function () {
|
|
||||||
var $this = $(this);
|
var $this = $(this);
|
||||||
|
|
||||||
|
var cfrom = $this.attr('data-copy-from');
|
||||||
|
$(cfrom).select();
|
||||||
|
document.execCommand('copy');
|
||||||
|
getSelection().removeAllRanges();
|
||||||
|
|
||||||
$this.tipsy("hide").attr('original-title', $this.data('after-title'));
|
$this.tipsy("hide").attr('original-title', $this.data('after-title'));
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
$this.tipsy("show");
|
$this.tipsy("show");
|
||||||
@ -359,8 +351,44 @@ var Gogs = {};
|
|||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
$this.tipsy('hide').attr('original-title', $this.data('original-title'));
|
$this.tipsy('hide').attr('original-title', $this.data('original-title'));
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}
|
|
||||||
}).addClass("js-copy-bind");
|
this.blur();
|
||||||
|
return;
|
||||||
|
});
|
||||||
|
|
||||||
|
$(selector).addClass("js-copy-bind");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
$(selector).zclip({
|
||||||
|
path: Gogs.AppSubUrl + "/js/ZeroClipboard.swf",
|
||||||
|
copy: function () {
|
||||||
|
var t = $(this).data("copy-val");
|
||||||
|
var to = $($(this).data("copy-from"));
|
||||||
|
var str = "";
|
||||||
|
if (t == "txt") {
|
||||||
|
str = to.text();
|
||||||
|
}
|
||||||
|
if (t == 'val') {
|
||||||
|
str = to.val();
|
||||||
|
}
|
||||||
|
if (t == 'html') {
|
||||||
|
str = to.html();
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
},
|
||||||
|
afterCopy: function () {
|
||||||
|
var $this = $(this);
|
||||||
|
$this.tipsy("hide").attr('original-title', $this.data('after-title'));
|
||||||
|
setTimeout(function () {
|
||||||
|
$this.tipsy("show");
|
||||||
|
}, 200);
|
||||||
|
setTimeout(function () {
|
||||||
|
$this.tipsy('hide').attr('original-title', $this.data('original-title'));
|
||||||
|
}, 2000);
|
||||||
|
}
|
||||||
|
}).addClass("js-copy-bind");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ func CreateRepo(ctx *middleware.Context, opt api.CreateRepoOption) {
|
|||||||
func CreateOrgRepo(ctx *middleware.Context, opt api.CreateRepoOption) {
|
func CreateOrgRepo(ctx *middleware.Context, opt api.CreateRepoOption) {
|
||||||
org, err := models.GetOrgByName(ctx.Params(":org"))
|
org, err := models.GetOrgByName(ctx.Params(":org"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == models.ErrUserNotExist {
|
if models.IsErrUserNotExist(err) {
|
||||||
ctx.Error(404)
|
ctx.Error(404)
|
||||||
} else {
|
} else {
|
||||||
ctx.Error(500)
|
ctx.Error(500)
|
||||||
@ -157,7 +157,7 @@ func CreateOrgRepo(ctx *middleware.Context, opt api.CreateRepoOption) {
|
|||||||
func MigrateRepo(ctx *middleware.Context, form auth.MigrateRepoForm) {
|
func MigrateRepo(ctx *middleware.Context, form auth.MigrateRepoForm) {
|
||||||
u, err := models.GetUserByName(ctx.Query("username"))
|
u, err := models.GetUserByName(ctx.Query("username"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == models.ErrUserNotExist {
|
if models.IsErrUserNotExist(err) {
|
||||||
ctx.HandleAPI(422, err)
|
ctx.HandleAPI(422, err)
|
||||||
} else {
|
} else {
|
||||||
ctx.HandleAPI(500, err)
|
ctx.HandleAPI(500, err)
|
||||||
@ -174,7 +174,7 @@ func MigrateRepo(ctx *middleware.Context, form auth.MigrateRepoForm) {
|
|||||||
if form.Uid != u.Id {
|
if form.Uid != u.Id {
|
||||||
org, err := models.GetUserById(form.Uid)
|
org, err := models.GetUserById(form.Uid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == models.ErrUserNotExist {
|
if models.IsErrUserNotExist(err) {
|
||||||
ctx.HandleAPI(422, err)
|
ctx.HandleAPI(422, err)
|
||||||
} else {
|
} else {
|
||||||
ctx.HandleAPI(500, err)
|
ctx.HandleAPI(500, err)
|
||||||
|
@ -61,7 +61,7 @@ func SearchUsers(ctx *middleware.Context) {
|
|||||||
func GetUserInfo(ctx *middleware.Context) {
|
func GetUserInfo(ctx *middleware.Context) {
|
||||||
u, err := models.GetUserByName(ctx.Params(":username"))
|
u, err := models.GetUserByName(ctx.Params(":username"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == models.ErrUserNotExist {
|
if models.IsErrUserNotExist(err) {
|
||||||
ctx.Error(404)
|
ctx.Error(404)
|
||||||
} else {
|
} else {
|
||||||
ctx.JSON(500, &base.ApiJsonErr{"GetUserByName: " + err.Error(), base.DOC_URL})
|
ctx.JSON(500, &base.ApiJsonErr{"GetUserByName: " + err.Error(), base.DOC_URL})
|
||||||
|
@ -100,7 +100,7 @@ func Invitation(ctx *middleware.Context) {
|
|||||||
uname := ctx.Query("uname")
|
uname := ctx.Query("uname")
|
||||||
u, err := models.GetUserByName(uname)
|
u, err := models.GetUserByName(uname)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == models.ErrUserNotExist {
|
if models.IsErrUserNotExist(err) {
|
||||||
ctx.Flash.Error(ctx.Tr("form.user_not_exist"))
|
ctx.Flash.Error(ctx.Tr("form.user_not_exist"))
|
||||||
ctx.Redirect(ctx.Org.OrgLink + "/invitations/new")
|
ctx.Redirect(ctx.Org.OrgLink + "/invitations/new")
|
||||||
} else {
|
} else {
|
||||||
|
@ -77,7 +77,7 @@ func TeamsAction(ctx *middleware.Context) {
|
|||||||
var u *models.User
|
var u *models.User
|
||||||
u, err = models.GetUserByName(uname)
|
u, err = models.GetUserByName(uname)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == models.ErrUserNotExist {
|
if models.IsErrUserNotExist(err) {
|
||||||
ctx.Flash.Error(ctx.Tr("form.user_not_exist"))
|
ctx.Flash.Error(ctx.Tr("form.user_not_exist"))
|
||||||
ctx.Redirect(ctx.Org.OrgLink + "/teams/" + ctx.Org.Team.LowerName)
|
ctx.Redirect(ctx.Org.OrgLink + "/teams/" + ctx.Org.Team.LowerName)
|
||||||
} else {
|
} else {
|
||||||
|
@ -55,7 +55,7 @@ func Http(ctx *middleware.Context) {
|
|||||||
|
|
||||||
repoUser, err := models.GetUserByName(username)
|
repoUser, err := models.GetUserByName(username)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == models.ErrUserNotExist {
|
if models.IsErrUserNotExist(err) {
|
||||||
ctx.Handle(404, "GetUserByName", nil)
|
ctx.Handle(404, "GetUserByName", nil)
|
||||||
} else {
|
} else {
|
||||||
ctx.Handle(500, "GetUserByName", err)
|
ctx.Handle(500, "GetUserByName", err)
|
||||||
@ -107,7 +107,7 @@ func Http(ctx *middleware.Context) {
|
|||||||
|
|
||||||
authUser, err = models.UserSignIn(authUsername, authPasswd)
|
authUser, err = models.UserSignIn(authUsername, authPasswd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err != models.ErrUserNotExist {
|
if !models.IsErrUserNotExist(err) {
|
||||||
ctx.Handle(500, "UserSignIn error: %v", err)
|
ctx.Handle(500, "UserSignIn error: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ func checkContextUser(ctx *middleware.Context, uid int64) *models.User {
|
|||||||
}
|
}
|
||||||
|
|
||||||
org, err := models.GetUserById(uid)
|
org, err := models.GetUserById(uid)
|
||||||
if err == models.ErrUserNotExist {
|
if models.IsErrUserNotExist(err) {
|
||||||
return ctx.User
|
return ctx.User
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ func SettingsPost(ctx *middleware.Context, form auth.RepoSettingForm) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if _, err = models.UserSignIn(ctx.User.Name, ctx.Query("password")); err != nil {
|
if _, err = models.UserSignIn(ctx.User.Name, ctx.Query("password")); err != nil {
|
||||||
if err == models.ErrUserNotExist {
|
if models.IsErrUserNotExist(err) {
|
||||||
ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_password"), SETTINGS_OPTIONS, nil)
|
ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_password"), SETTINGS_OPTIONS, nil)
|
||||||
} else {
|
} else {
|
||||||
ctx.Handle(500, "UserSignIn", err)
|
ctx.Handle(500, "UserSignIn", err)
|
||||||
@ -151,7 +151,7 @@ func SettingsPost(ctx *middleware.Context, form auth.RepoSettingForm) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if _, err := models.UserSignIn(ctx.User.Name, ctx.Query("password")); err != nil {
|
if _, err := models.UserSignIn(ctx.User.Name, ctx.Query("password")); err != nil {
|
||||||
if err == models.ErrUserNotExist {
|
if models.IsErrUserNotExist(err) {
|
||||||
ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_password"), SETTINGS_OPTIONS, nil)
|
ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_password"), SETTINGS_OPTIONS, nil)
|
||||||
} else {
|
} else {
|
||||||
ctx.Handle(500, "UserSignIn", err)
|
ctx.Handle(500, "UserSignIn", err)
|
||||||
@ -185,7 +185,7 @@ func SettingsCollaboration(ctx *middleware.Context) {
|
|||||||
|
|
||||||
u, err := models.GetUserByName(name)
|
u, err := models.GetUserByName(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == models.ErrUserNotExist {
|
if models.IsErrUserNotExist(err) {
|
||||||
ctx.Flash.Error(ctx.Tr("form.user_not_exist"))
|
ctx.Flash.Error(ctx.Tr("form.user_not_exist"))
|
||||||
ctx.Redirect(setting.AppSubUrl + ctx.Req.URL.Path)
|
ctx.Redirect(setting.AppSubUrl + ctx.Req.URL.Path)
|
||||||
} else {
|
} else {
|
||||||
|
@ -60,7 +60,7 @@ func SignIn(ctx *middleware.Context) {
|
|||||||
|
|
||||||
u, err := models.GetUserByName(uname)
|
u, err := models.GetUserByName(uname)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err != models.ErrUserNotExist {
|
if !models.IsErrUserNotExist(err) {
|
||||||
ctx.Handle(500, "GetUserByName", err)
|
ctx.Handle(500, "GetUserByName", err)
|
||||||
} else {
|
} else {
|
||||||
ctx.HTML(200, SIGNIN)
|
ctx.HTML(200, SIGNIN)
|
||||||
@ -105,7 +105,7 @@ func SignInPost(ctx *middleware.Context, form auth.SignInForm) {
|
|||||||
|
|
||||||
u, err := models.UserSignIn(form.UserName, form.Password)
|
u, err := models.UserSignIn(form.UserName, form.Password)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == models.ErrUserNotExist {
|
if models.IsErrUserNotExist(err) {
|
||||||
ctx.RenderWithErr(ctx.Tr("form.username_password_incorrect"), SIGNIN, &form)
|
ctx.RenderWithErr(ctx.Tr("form.username_password_incorrect"), SIGNIN, &form)
|
||||||
} else {
|
} else {
|
||||||
ctx.Handle(500, "UserSignIn", err)
|
ctx.Handle(500, "UserSignIn", err)
|
||||||
@ -328,7 +328,7 @@ func Activate(ctx *middleware.Context) {
|
|||||||
user.IsActive = true
|
user.IsActive = true
|
||||||
user.Rands = models.GetUserSalt()
|
user.Rands = models.GetUserSalt()
|
||||||
if err := models.UpdateUser(user); err != nil {
|
if err := models.UpdateUser(user); err != nil {
|
||||||
if err == models.ErrUserNotExist {
|
if models.IsErrUserNotExist(err) {
|
||||||
ctx.Error(404)
|
ctx.Error(404)
|
||||||
} else {
|
} else {
|
||||||
ctx.Handle(500, "UpdateUser", err)
|
ctx.Handle(500, "UpdateUser", err)
|
||||||
@ -391,7 +391,7 @@ func ForgotPasswdPost(ctx *middleware.Context) {
|
|||||||
email := ctx.Query("email")
|
email := ctx.Query("email")
|
||||||
u, err := models.GetUserByEmail(email)
|
u, err := models.GetUserByEmail(email)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == models.ErrUserNotExist {
|
if models.IsErrUserNotExist(err) {
|
||||||
ctx.Data["Err_Email"] = true
|
ctx.Data["Err_Email"] = true
|
||||||
ctx.RenderWithErr(ctx.Tr("auth.email_not_associate"), FORGOT_PASSWORD, nil)
|
ctx.RenderWithErr(ctx.Tr("auth.email_not_associate"), FORGOT_PASSWORD, nil)
|
||||||
} else {
|
} else {
|
||||||
|
@ -38,7 +38,7 @@ func Dashboard(ctx *middleware.Context) {
|
|||||||
// Organization.
|
// Organization.
|
||||||
org, err := models.GetUserByName(orgName)
|
org, err := models.GetUserByName(orgName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == models.ErrUserNotExist {
|
if models.IsErrUserNotExist(err) {
|
||||||
ctx.Handle(404, "GetUserByName", err)
|
ctx.Handle(404, "GetUserByName", err)
|
||||||
} else {
|
} else {
|
||||||
ctx.Handle(500, "GetUserByName", err)
|
ctx.Handle(500, "GetUserByName", err)
|
||||||
@ -115,7 +115,7 @@ func Dashboard(ctx *middleware.Context) {
|
|||||||
// FIXME: cache results?
|
// FIXME: cache results?
|
||||||
u, err := models.GetUserByName(act.ActUserName)
|
u, err := models.GetUserByName(act.ActUserName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == models.ErrUserNotExist {
|
if models.IsErrUserNotExist(err) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
ctx.Handle(500, "GetUserByName", err)
|
ctx.Handle(500, "GetUserByName", err)
|
||||||
@ -176,7 +176,7 @@ func Profile(ctx *middleware.Context) {
|
|||||||
|
|
||||||
u, err := models.GetUserByName(uname)
|
u, err := models.GetUserByName(uname)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == models.ErrUserNotExist {
|
if models.IsErrUserNotExist(err) {
|
||||||
ctx.Handle(404, "GetUserByName", err)
|
ctx.Handle(404, "GetUserByName", err)
|
||||||
} else {
|
} else {
|
||||||
ctx.Handle(500, "GetUserByName", err)
|
ctx.Handle(500, "GetUserByName", err)
|
||||||
@ -223,7 +223,7 @@ func Profile(ctx *middleware.Context) {
|
|||||||
// FIXME: cache results?
|
// FIXME: cache results?
|
||||||
u, err := models.GetUserByName(act.ActUserName)
|
u, err := models.GetUserByName(act.ActUserName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == models.ErrUserNotExist {
|
if models.IsErrUserNotExist(err) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
ctx.Handle(500, "GetUserByName", err)
|
ctx.Handle(500, "GetUserByName", err)
|
||||||
@ -247,10 +247,10 @@ func Profile(ctx *middleware.Context) {
|
|||||||
func Email2User(ctx *middleware.Context) {
|
func Email2User(ctx *middleware.Context) {
|
||||||
u, err := models.GetUserByEmail(ctx.Query("email"))
|
u, err := models.GetUserByEmail(ctx.Query("email"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == models.ErrUserNotExist {
|
if models.IsErrUserNotExist(err) {
|
||||||
ctx.Handle(404, "user.Email2User(GetUserByEmail)", err)
|
ctx.Handle(404, "GetUserByEmail", err)
|
||||||
} else {
|
} else {
|
||||||
ctx.Handle(500, "user.Email2User(GetUserByEmail)", err)
|
ctx.Handle(500, "GetUserByEmail", err)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html{{if .BrowserSupportsCopy}} class="is-copy-enabled"{{end}}>
|
||||||
<head data-suburl="{{AppSubUrl}}">
|
<head data-suburl="{{AppSubUrl}}">
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
|
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
{{.CsrfTokenHtml}}
|
{{.CsrfTokenHtml}}
|
||||||
<input type="hidden" name="action" value="update">
|
<input type="hidden" name="action" value="update">
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="req" for="orgname">{{.i18n.Tr "username"}}</label>
|
<label class="req" for="orgname">{{.i18n.Tr "org.org_name_holder"}}</label>
|
||||||
<input class="ipt ipt-large ipt-radius {{if .Err_UserName}}ipt-error{{end}}" id="orgname" name="uname" value="{{.Org.Name}}" data-orgname="{{.Org.Name}}" required />
|
<input class="ipt ipt-large ipt-radius {{if .Err_UserName}}ipt-error{{end}}" id="orgname" name="uname" value="{{.Org.Name}}" data-orgname="{{.Org.Name}}" required />
|
||||||
</div>
|
</div>
|
||||||
<div class="white-popup-block mfp-hide" id="change-orgname-modal">
|
<div class="white-popup-block mfp-hide" id="change-orgname-modal">
|
||||||
|
Loading…
Reference in New Issue
Block a user