mirror of https://github.com/gogs/gogs.git
models: rename ErrUserNotExist -> errors.UserNotExist
parent
4e64e71e28
commit
0ccd7c97ab
|
@ -17,6 +17,7 @@ import (
|
||||||
log "gopkg.in/clog.v1"
|
log "gopkg.in/clog.v1"
|
||||||
|
|
||||||
"github.com/gogits/gogs/models"
|
"github.com/gogits/gogs/models"
|
||||||
|
"github.com/gogits/gogs/models/errors"
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
http "github.com/gogits/gogs/routers/repo"
|
http "github.com/gogits/gogs/routers/repo"
|
||||||
)
|
)
|
||||||
|
@ -153,7 +154,7 @@ func runServ(c *cli.Context) error {
|
||||||
|
|
||||||
owner, err := models.GetUserByName(ownerName)
|
owner, err := models.GetUserByName(ownerName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrUserNotExist(err) {
|
if errors.IsUserNotExist(err) {
|
||||||
fail("Repository owner does not exist", "Unregistered owner: %s", ownerName)
|
fail("Repository owner does not exist", "Unregistered owner: %s", ownerName)
|
||||||
}
|
}
|
||||||
fail("Internal error", "Fail to get repository owner '%s': %v", ownerName, err)
|
fail("Internal error", "Fail to get repository owner '%s': %v", ownerName, err)
|
||||||
|
|
|
@ -20,6 +20,7 @@ import (
|
||||||
"github.com/gogits/git-module"
|
"github.com/gogits/git-module"
|
||||||
api "github.com/gogits/go-gogs-client"
|
api "github.com/gogits/go-gogs-client"
|
||||||
|
|
||||||
|
"github.com/gogits/gogs/models/errors"
|
||||||
"github.com/gogits/gogs/modules/base"
|
"github.com/gogits/gogs/modules/base"
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
)
|
)
|
||||||
|
@ -292,7 +293,7 @@ func (push *PushCommits) AvatarLink(email string) string {
|
||||||
u, err := GetUserByEmail(email)
|
u, err := GetUserByEmail(email)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
push.avatars[email] = base.AvatarLink(email)
|
push.avatars[email] = base.AvatarLink(email)
|
||||||
if !IsErrUserNotExist(err) {
|
if !errors.IsUserNotExist(err) {
|
||||||
log.Error(4, "GetUserByEmail: %v", err)
|
log.Error(4, "GetUserByEmail: %v", err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -15,6 +15,7 @@ import (
|
||||||
|
|
||||||
api "github.com/gogits/go-gogs-client"
|
api "github.com/gogits/go-gogs-client"
|
||||||
|
|
||||||
|
"github.com/gogits/gogs/models/errors"
|
||||||
"github.com/gogits/gogs/modules/markdown"
|
"github.com/gogits/gogs/modules/markdown"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -95,7 +96,7 @@ func (c *Comment) loadAttributes(e Engine) (err error) {
|
||||||
if c.Poster == nil {
|
if c.Poster == nil {
|
||||||
c.Poster, err = GetUserByID(c.PosterID)
|
c.Poster, err = GetUserByID(c.PosterID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if IsErrUserNotExist(err) {
|
if errors.IsUserNotExist(err) {
|
||||||
c.PosterID = -1
|
c.PosterID = -1
|
||||||
c.Poster = NewGhostUser()
|
c.Poster = NewGhostUser()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -54,20 +54,6 @@ 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
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,20 @@ func (err EmptyName) Error() string {
|
||||||
return "empty name"
|
return "empty name"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type UserNotExist struct {
|
||||||
|
UserID int64
|
||||||
|
Name string
|
||||||
|
}
|
||||||
|
|
||||||
|
func IsUserNotExist(err error) bool {
|
||||||
|
_, ok := err.(UserNotExist)
|
||||||
|
return ok
|
||||||
|
}
|
||||||
|
|
||||||
|
func (err UserNotExist) Error() string {
|
||||||
|
return fmt.Sprintf("user does not exist [user_id: %d, name: %s]", err.UserID, err.Name)
|
||||||
|
}
|
||||||
|
|
||||||
type UserNotKeyOwner struct {
|
type UserNotKeyOwner struct {
|
||||||
KeyID int64
|
KeyID int64
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ func (issue *Issue) loadAttributes(e Engine) (err error) {
|
||||||
if issue.Poster == nil {
|
if issue.Poster == nil {
|
||||||
issue.Poster, err = getUserByID(e, issue.PosterID)
|
issue.Poster, err = getUserByID(e, issue.PosterID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if IsErrUserNotExist(err) {
|
if errors.IsUserNotExist(err) {
|
||||||
issue.PosterID = -1
|
issue.PosterID = -1
|
||||||
issue.Poster = NewGhostUser()
|
issue.Poster = NewGhostUser()
|
||||||
} else {
|
} else {
|
||||||
|
@ -390,7 +390,7 @@ func (i *Issue) GetAssignee() (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
i.Assignee, err = GetUserByID(i.AssigneeID)
|
i.Assignee, err = GetUserByID(i.AssigneeID)
|
||||||
if IsErrUserNotExist(err) {
|
if errors.IsUserNotExist(err) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
@ -595,7 +595,7 @@ func (issue *Issue) ChangeAssignee(doer *User, assigneeID int64) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
issue.Assignee, err = GetUserByID(issue.AssigneeID)
|
issue.Assignee, err = GetUserByID(issue.AssigneeID)
|
||||||
if err != nil && !IsErrUserNotExist(err) {
|
if err != nil && !errors.IsUserNotExist(err) {
|
||||||
log.Error(4, "GetUserByID [assignee_id: %v]: %v", issue.AssigneeID, err)
|
log.Error(4, "GetUserByID [assignee_id: %v]: %v", issue.AssigneeID, err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -668,7 +668,7 @@ func newIssue(e *xorm.Session, opts NewIssueOptions) (err error) {
|
||||||
|
|
||||||
if opts.Issue.AssigneeID > 0 {
|
if opts.Issue.AssigneeID > 0 {
|
||||||
assignee, err := getUserByID(e, opts.Issue.AssigneeID)
|
assignee, err := getUserByID(e, opts.Issue.AssigneeID)
|
||||||
if err != nil && !IsErrUserNotExist(err) {
|
if err != nil && !errors.IsUserNotExist(err) {
|
||||||
return fmt.Errorf("getUserByID: %v", err)
|
return fmt.Errorf("getUserByID: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -296,7 +296,7 @@ func LoginViaLDAP(user *User, login, password string, source *LoginSource, autoR
|
||||||
username, fn, sn, mail, isAdmin, succeed := source.Cfg.(*LDAPConfig).SearchEntry(login, password, source.Type == LOGIN_DLDAP)
|
username, fn, sn, mail, isAdmin, succeed := source.Cfg.(*LDAPConfig).SearchEntry(login, password, source.Type == LOGIN_DLDAP)
|
||||||
if !succeed {
|
if !succeed {
|
||||||
// User not in LDAP, do nothing
|
// User not in LDAP, do nothing
|
||||||
return nil, ErrUserNotExist{0, login}
|
return nil, errors.UserNotExist{0, login}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !autoRegister {
|
if !autoRegister {
|
||||||
|
@ -404,9 +404,9 @@ func LoginViaSMTP(user *User, login, password string, sourceID int64, cfg *SMTPC
|
||||||
if len(cfg.AllowedDomains) > 0 {
|
if len(cfg.AllowedDomains) > 0 {
|
||||||
idx := strings.Index(login, "@")
|
idx := strings.Index(login, "@")
|
||||||
if idx == -1 {
|
if idx == -1 {
|
||||||
return nil, ErrUserNotExist{0, login}
|
return nil, errors.UserNotExist{0, login}
|
||||||
} else if !com.IsSliceContainsStr(strings.Split(cfg.AllowedDomains, ","), login[idx+1:]) {
|
} else if !com.IsSliceContainsStr(strings.Split(cfg.AllowedDomains, ","), login[idx+1:]) {
|
||||||
return nil, ErrUserNotExist{0, login}
|
return nil, errors.UserNotExist{0, login}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -425,7 +425,7 @@ func LoginViaSMTP(user *User, login, password string, sourceID int64, cfg *SMTPC
|
||||||
tperr, ok := err.(*textproto.Error)
|
tperr, ok := err.(*textproto.Error)
|
||||||
if (ok && tperr.Code == 535) ||
|
if (ok && tperr.Code == 535) ||
|
||||||
strings.Contains(err.Error(), "Username and Password not accepted") {
|
strings.Contains(err.Error(), "Username and Password not accepted") {
|
||||||
return nil, ErrUserNotExist{0, login}
|
return nil, errors.UserNotExist{0, login}
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -465,7 +465,7 @@ func LoginViaSMTP(user *User, login, password string, sourceID int64, cfg *SMTPC
|
||||||
func LoginViaPAM(user *User, login, password string, sourceID int64, cfg *PAMConfig, autoRegister bool) (*User, error) {
|
func LoginViaPAM(user *User, login, password string, sourceID int64, cfg *PAMConfig, autoRegister bool) (*User, error) {
|
||||||
if err := pam.PAMAuth(cfg.ServiceName, login, password); err != nil {
|
if err := pam.PAMAuth(cfg.ServiceName, login, password); err != nil {
|
||||||
if strings.Contains(err.Error(), "Authentication failure") {
|
if strings.Contains(err.Error(), "Authentication failure") {
|
||||||
return nil, ErrUserNotExist{0, login}
|
return nil, errors.UserNotExist{0, login}
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -525,7 +525,7 @@ func UserSignIn(username, password string) (*User, error) {
|
||||||
return user, nil
|
return user, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, ErrUserNotExist{user.ID, user.Name}
|
return nil, errors.UserNotExist{user.ID, user.Name}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
var source LoginSource
|
var source LoginSource
|
||||||
|
@ -554,5 +554,5 @@ func UserSignIn(username, password string) (*User, error) {
|
||||||
log.Warn("Failed to login '%s' via '%s': %v", username, source.Name, err)
|
log.Warn("Failed to login '%s' via '%s': %v", username, source.Name, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, ErrUserNotExist{user.ID, user.Name}
|
return nil, errors.UserNotExist{user.ID, user.Name}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ import (
|
||||||
"github.com/gogits/git-module"
|
"github.com/gogits/git-module"
|
||||||
api "github.com/gogits/go-gogs-client"
|
api "github.com/gogits/go-gogs-client"
|
||||||
|
|
||||||
|
"github.com/gogits/gogs/models/errors"
|
||||||
"github.com/gogits/gogs/modules/process"
|
"github.com/gogits/gogs/modules/process"
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
"github.com/gogits/gogs/modules/sync"
|
"github.com/gogits/gogs/modules/sync"
|
||||||
|
@ -101,7 +102,7 @@ func (pr *PullRequest) loadAttributes(e Engine) (err error) {
|
||||||
|
|
||||||
if pr.HasMerged && pr.Merger == nil {
|
if pr.HasMerged && pr.Merger == nil {
|
||||||
pr.Merger, err = getUserByID(e, pr.MergerID)
|
pr.Merger, err = getUserByID(e, pr.MergerID)
|
||||||
if IsErrUserNotExist(err) {
|
if errors.IsUserNotExist(err) {
|
||||||
pr.MergerID = -1
|
pr.MergerID = -1
|
||||||
pr.Merger = NewGhostUser()
|
pr.Merger = NewGhostUser()
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
|
|
|
@ -16,6 +16,7 @@ import (
|
||||||
"github.com/gogits/git-module"
|
"github.com/gogits/git-module"
|
||||||
api "github.com/gogits/go-gogs-client"
|
api "github.com/gogits/go-gogs-client"
|
||||||
|
|
||||||
|
"github.com/gogits/gogs/models/errors"
|
||||||
"github.com/gogits/gogs/modules/process"
|
"github.com/gogits/gogs/modules/process"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -67,7 +68,7 @@ func (r *Release) loadAttributes(e Engine) (err error) {
|
||||||
if r.Publisher == nil {
|
if r.Publisher == nil {
|
||||||
r.Publisher, err = getUserByID(e, r.PublisherID)
|
r.Publisher, err = getUserByID(e, r.PublisherID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if IsErrUserNotExist(err) {
|
if errors.IsUserNotExist(err) {
|
||||||
r.PublisherID = -1
|
r.PublisherID = -1
|
||||||
r.Publisher = NewGhostUser()
|
r.Publisher = NewGhostUser()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -896,7 +896,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{id, ""}
|
return nil, errors.UserNotExist{id, ""}
|
||||||
}
|
}
|
||||||
return u, nil
|
return u, nil
|
||||||
}
|
}
|
||||||
|
@ -912,7 +912,7 @@ func GetAssigneeByID(repo *Repository, userID int64) (*User, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if !has {
|
} else if !has {
|
||||||
return nil, ErrUserNotExist{userID, ""}
|
return nil, errors.UserNotExist{userID, ""}
|
||||||
}
|
}
|
||||||
return GetUserByID(userID)
|
return GetUserByID(userID)
|
||||||
}
|
}
|
||||||
|
@ -920,14 +920,14 @@ func GetAssigneeByID(repo *Repository, userID 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{0, name}
|
return nil, errors.UserNotExist{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{0, name}
|
return nil, errors.UserNotExist{0, name}
|
||||||
}
|
}
|
||||||
return u, nil
|
return u, nil
|
||||||
}
|
}
|
||||||
|
@ -1005,7 +1005,7 @@ 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{0, "email"}
|
return nil, errors.UserNotExist{0, "email"}
|
||||||
}
|
}
|
||||||
|
|
||||||
email = strings.ToLower(email)
|
email = strings.ToLower(email)
|
||||||
|
@ -1029,7 +1029,7 @@ func GetUserByEmail(email string) (*User, error) {
|
||||||
return GetUserByID(emailAddress.UID)
|
return GetUserByID(emailAddress.UID)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, ErrUserNotExist{0, email}
|
return nil, errors.UserNotExist{0, email}
|
||||||
}
|
}
|
||||||
|
|
||||||
type SearchUserOptions struct {
|
type SearchUserOptions struct {
|
||||||
|
|
|
@ -177,7 +177,7 @@ func MakeEmailPrimary(email *EmailAddress) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
} else if !has {
|
} else if !has {
|
||||||
return ErrUserNotExist{email.UID, ""}
|
return errors.UserNotExist{email.UID, ""}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the former primary email doesn't disappear.
|
// Make sure the former primary email doesn't disappear.
|
||||||
|
|
|
@ -14,6 +14,7 @@ import (
|
||||||
"gopkg.in/macaron.v1"
|
"gopkg.in/macaron.v1"
|
||||||
|
|
||||||
"github.com/gogits/gogs/models"
|
"github.com/gogits/gogs/models"
|
||||||
|
"github.com/gogits/gogs/models/errors"
|
||||||
"github.com/gogits/gogs/modules/base"
|
"github.com/gogits/gogs/modules/base"
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
)
|
)
|
||||||
|
@ -65,7 +66,7 @@ func SignedInID(ctx *macaron.Context, 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 !models.IsErrUserNotExist(err) {
|
if !errors.IsUserNotExist(err) {
|
||||||
log.Error(2, "GetUserById: %v", err)
|
log.Error(2, "GetUserById: %v", err)
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
|
@ -90,7 +91,7 @@ func SignedInUser(ctx *macaron.Context, 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 !models.IsErrUserNotExist(err) {
|
if !errors.IsUserNotExist(err) {
|
||||||
log.Error(4, "GetUserByName: %v", err)
|
log.Error(4, "GetUserByName: %v", err)
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
@ -125,7 +126,7 @@ func SignedInUser(ctx *macaron.Context, 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 !models.IsErrUserNotExist(err) {
|
if !errors.IsUserNotExist(err) {
|
||||||
log.Error(4, "UserSignIn: %v", err)
|
log.Error(4, "UserSignIn: %v", err)
|
||||||
}
|
}
|
||||||
return nil, false
|
return nil, false
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"gopkg.in/macaron.v1"
|
"gopkg.in/macaron.v1"
|
||||||
|
|
||||||
"github.com/gogits/gogs/models"
|
"github.com/gogits/gogs/models"
|
||||||
|
"github.com/gogits/gogs/models/errors"
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -49,11 +50,7 @@ func HandleOrgAssignment(ctx *Context, args ...bool) {
|
||||||
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 models.IsErrUserNotExist(err) {
|
ctx.NotFoundOrServerError("GetUserByName", errors.IsUserNotExist, err)
|
||||||
ctx.Handle(404, "GetUserByName", err)
|
|
||||||
} else {
|
|
||||||
ctx.Handle(500, "GetUserByName", err)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
org := ctx.Org.Organization
|
org := ctx.Org.Organization
|
||||||
|
|
|
@ -18,6 +18,7 @@ import (
|
||||||
"github.com/gogits/git-module"
|
"github.com/gogits/git-module"
|
||||||
|
|
||||||
"github.com/gogits/gogs/models"
|
"github.com/gogits/gogs/models"
|
||||||
|
"github.com/gogits/gogs/models/errors"
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -169,7 +170,7 @@ func RepoAssignment(args ...bool) macaron.Handler {
|
||||||
} else {
|
} else {
|
||||||
owner, err = models.GetUserByName(ownerName)
|
owner, err = models.GetUserByName(ownerName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrUserNotExist(err) {
|
if errors.IsUserNotExist(err) {
|
||||||
if ctx.Query("go-get") == "1" {
|
if ctx.Query("go-get") == "1" {
|
||||||
earlyResponseForGoGetMeta(ctx)
|
earlyResponseForGoGetMeta(ctx)
|
||||||
return
|
return
|
||||||
|
|
|
@ -13,6 +13,7 @@ import (
|
||||||
api "github.com/gogits/go-gogs-client"
|
api "github.com/gogits/go-gogs-client"
|
||||||
|
|
||||||
"github.com/gogits/gogs/models"
|
"github.com/gogits/gogs/models"
|
||||||
|
"github.com/gogits/gogs/models/errors"
|
||||||
"github.com/gogits/gogs/modules/context"
|
"github.com/gogits/gogs/modules/context"
|
||||||
"github.com/gogits/gogs/modules/form"
|
"github.com/gogits/gogs/modules/form"
|
||||||
"github.com/gogits/gogs/routers/api/v1/admin"
|
"github.com/gogits/gogs/routers/api/v1/admin"
|
||||||
|
@ -38,7 +39,7 @@ func repoAssignment() macaron.Handler {
|
||||||
} else {
|
} else {
|
||||||
owner, err = models.GetUserByName(userName)
|
owner, err = models.GetUserByName(userName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrUserNotExist(err) {
|
if errors.IsUserNotExist(err) {
|
||||||
ctx.Status(404)
|
ctx.Status(404)
|
||||||
} else {
|
} else {
|
||||||
ctx.Error(500, "GetUserByName", err)
|
ctx.Error(500, "GetUserByName", err)
|
||||||
|
@ -137,7 +138,7 @@ func orgAssignment(args ...bool) macaron.Handler {
|
||||||
if assignOrg {
|
if assignOrg {
|
||||||
ctx.Org.Organization, err = models.GetUserByName(ctx.Params(":orgname"))
|
ctx.Org.Organization, err = models.GetUserByName(ctx.Params(":orgname"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrUserNotExist(err) {
|
if errors.IsUserNotExist(err) {
|
||||||
ctx.Status(404)
|
ctx.Status(404)
|
||||||
} else {
|
} else {
|
||||||
ctx.Error(500, "GetUserByName", err)
|
ctx.Error(500, "GetUserByName", err)
|
||||||
|
@ -149,7 +150,7 @@ func orgAssignment(args ...bool) macaron.Handler {
|
||||||
if assignTeam {
|
if assignTeam {
|
||||||
ctx.Org.Team, err = models.GetTeamByID(ctx.ParamsInt64(":teamid"))
|
ctx.Org.Team, err = models.GetTeamByID(ctx.ParamsInt64(":teamid"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrUserNotExist(err) {
|
if errors.IsUserNotExist(err) {
|
||||||
ctx.Status(404)
|
ctx.Status(404)
|
||||||
} else {
|
} else {
|
||||||
ctx.Error(500, "GetTeamById", err)
|
ctx.Error(500, "GetTeamById", err)
|
||||||
|
|
|
@ -8,13 +8,14 @@ import (
|
||||||
api "github.com/gogits/go-gogs-client"
|
api "github.com/gogits/go-gogs-client"
|
||||||
|
|
||||||
"github.com/gogits/gogs/models"
|
"github.com/gogits/gogs/models"
|
||||||
|
"github.com/gogits/gogs/models/errors"
|
||||||
"github.com/gogits/gogs/modules/context"
|
"github.com/gogits/gogs/modules/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ListCollaborators(ctx *context.APIContext) {
|
func ListCollaborators(ctx *context.APIContext) {
|
||||||
collaborators, err := ctx.Repo.Repository.GetCollaborators()
|
collaborators, err := ctx.Repo.Repository.GetCollaborators()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrUserNotExist(err) {
|
if errors.IsUserNotExist(err) {
|
||||||
ctx.Error(422, "", err)
|
ctx.Error(422, "", err)
|
||||||
} else {
|
} else {
|
||||||
ctx.Error(500, "GetCollaborators", err)
|
ctx.Error(500, "GetCollaborators", err)
|
||||||
|
@ -32,7 +33,7 @@ func ListCollaborators(ctx *context.APIContext) {
|
||||||
func AddCollaborator(ctx *context.APIContext, form api.AddCollaboratorOption) {
|
func AddCollaborator(ctx *context.APIContext, form api.AddCollaboratorOption) {
|
||||||
collaborator, err := models.GetUserByName(ctx.Params(":collaborator"))
|
collaborator, err := models.GetUserByName(ctx.Params(":collaborator"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrUserNotExist(err) {
|
if errors.IsUserNotExist(err) {
|
||||||
ctx.Error(422, "", err)
|
ctx.Error(422, "", err)
|
||||||
} else {
|
} else {
|
||||||
ctx.Error(500, "GetUserByName", err)
|
ctx.Error(500, "GetUserByName", err)
|
||||||
|
@ -58,7 +59,7 @@ func AddCollaborator(ctx *context.APIContext, form api.AddCollaboratorOption) {
|
||||||
func IsCollaborator(ctx *context.APIContext) {
|
func IsCollaborator(ctx *context.APIContext) {
|
||||||
collaborator, err := models.GetUserByName(ctx.Params(":collaborator"))
|
collaborator, err := models.GetUserByName(ctx.Params(":collaborator"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrUserNotExist(err) {
|
if errors.IsUserNotExist(err) {
|
||||||
ctx.Error(422, "", err)
|
ctx.Error(422, "", err)
|
||||||
} else {
|
} else {
|
||||||
ctx.Error(500, "GetUserByName", err)
|
ctx.Error(500, "GetUserByName", err)
|
||||||
|
@ -82,7 +83,7 @@ func IsCollaborator(ctx *context.APIContext) {
|
||||||
func DeleteCollaborator(ctx *context.APIContext) {
|
func DeleteCollaborator(ctx *context.APIContext) {
|
||||||
collaborator, err := models.GetUserByName(ctx.Params(":collaborator"))
|
collaborator, err := models.GetUserByName(ctx.Params(":collaborator"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrUserNotExist(err) {
|
if errors.IsUserNotExist(err) {
|
||||||
ctx.Error(422, "", err)
|
ctx.Error(422, "", err)
|
||||||
} else {
|
} else {
|
||||||
ctx.Error(500, "GetUserByName", err)
|
ctx.Error(500, "GetUserByName", err)
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
api "github.com/gogits/go-gogs-client"
|
api "github.com/gogits/go-gogs-client"
|
||||||
|
|
||||||
"github.com/gogits/gogs/models"
|
"github.com/gogits/gogs/models"
|
||||||
|
"github.com/gogits/gogs/models/errors"
|
||||||
"github.com/gogits/gogs/modules/context"
|
"github.com/gogits/gogs/modules/context"
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
)
|
)
|
||||||
|
@ -86,7 +87,7 @@ func CreateIssue(ctx *context.APIContext, form api.CreateIssueOption) {
|
||||||
if len(form.Assignee) > 0 {
|
if len(form.Assignee) > 0 {
|
||||||
assignee, err := models.GetUserByName(form.Assignee)
|
assignee, err := models.GetUserByName(form.Assignee)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrUserNotExist(err) {
|
if errors.IsUserNotExist(err) {
|
||||||
ctx.Error(422, "", fmt.Sprintf("Assignee does not exist: [name: %s]", form.Assignee))
|
ctx.Error(422, "", fmt.Sprintf("Assignee does not exist: [name: %s]", form.Assignee))
|
||||||
} else {
|
} else {
|
||||||
ctx.Error(500, "GetUserByName", err)
|
ctx.Error(500, "GetUserByName", err)
|
||||||
|
@ -152,7 +153,7 @@ func EditIssue(ctx *context.APIContext, form api.EditIssueOption) {
|
||||||
} else {
|
} else {
|
||||||
assignee, err := models.GetUserByName(*form.Assignee)
|
assignee, err := models.GetUserByName(*form.Assignee)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrUserNotExist(err) {
|
if errors.IsUserNotExist(err) {
|
||||||
ctx.Error(422, "", fmt.Sprintf("assignee does not exist: [name: %s]", *form.Assignee))
|
ctx.Error(422, "", fmt.Sprintf("assignee does not exist: [name: %s]", *form.Assignee))
|
||||||
} else {
|
} else {
|
||||||
ctx.Error(500, "GetUserByName", err)
|
ctx.Error(500, "GetUserByName", err)
|
||||||
|
|
|
@ -12,6 +12,7 @@ import (
|
||||||
api "github.com/gogits/go-gogs-client"
|
api "github.com/gogits/go-gogs-client"
|
||||||
|
|
||||||
"github.com/gogits/gogs/models"
|
"github.com/gogits/gogs/models"
|
||||||
|
"github.com/gogits/gogs/models/errors"
|
||||||
"github.com/gogits/gogs/modules/context"
|
"github.com/gogits/gogs/modules/context"
|
||||||
"github.com/gogits/gogs/modules/form"
|
"github.com/gogits/gogs/modules/form"
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
|
@ -80,7 +81,7 @@ func Search(ctx *context.APIContext) {
|
||||||
func listUserRepositories(ctx *context.APIContext, username string) {
|
func listUserRepositories(ctx *context.APIContext, username string) {
|
||||||
user, err := models.GetUserByName(username)
|
user, err := models.GetUserByName(username)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.NotFoundOrServerError("GetUserByName", models.IsErrUserNotExist, err)
|
ctx.NotFoundOrServerError("GetUserByName", errors.IsUserNotExist, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,7 +191,7 @@ func Create(ctx *context.APIContext, opt api.CreateRepoOption) {
|
||||||
func CreateOrgRepo(ctx *context.APIContext, opt api.CreateRepoOption) {
|
func CreateOrgRepo(ctx *context.APIContext, opt api.CreateRepoOption) {
|
||||||
org, err := models.GetOrgByName(ctx.Params(":org"))
|
org, err := models.GetOrgByName(ctx.Params(":org"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrUserNotExist(err) {
|
if errors.IsUserNotExist(err) {
|
||||||
ctx.Error(422, "", err)
|
ctx.Error(422, "", err)
|
||||||
} else {
|
} else {
|
||||||
ctx.Error(500, "GetOrgByName", err)
|
ctx.Error(500, "GetOrgByName", err)
|
||||||
|
@ -213,7 +214,7 @@ func Migrate(ctx *context.APIContext, f form.MigrateRepo) {
|
||||||
if f.Uid != ctxUser.ID {
|
if f.Uid != ctxUser.ID {
|
||||||
org, err := models.GetUserByID(f.Uid)
|
org, err := models.GetUserByID(f.Uid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrUserNotExist(err) {
|
if errors.IsUserNotExist(err) {
|
||||||
ctx.Error(422, "", err)
|
ctx.Error(422, "", err)
|
||||||
} else {
|
} else {
|
||||||
ctx.Error(500, "GetUserByID", err)
|
ctx.Error(500, "GetUserByID", err)
|
||||||
|
@ -280,7 +281,7 @@ func Migrate(ctx *context.APIContext, f form.MigrateRepo) {
|
||||||
func parseOwnerAndRepo(ctx *context.APIContext) (*models.User, *models.Repository) {
|
func parseOwnerAndRepo(ctx *context.APIContext) (*models.User, *models.Repository) {
|
||||||
owner, err := models.GetUserByName(ctx.Params(":username"))
|
owner, err := models.GetUserByName(ctx.Params(":username"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrUserNotExist(err) {
|
if errors.IsUserNotExist(err) {
|
||||||
ctx.Error(422, "", err)
|
ctx.Error(422, "", err)
|
||||||
} else {
|
} else {
|
||||||
ctx.Error(500, "GetUserByName", err)
|
ctx.Error(500, "GetUserByName", err)
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
api "github.com/gogits/go-gogs-client"
|
api "github.com/gogits/go-gogs-client"
|
||||||
|
|
||||||
"github.com/gogits/gogs/models"
|
"github.com/gogits/gogs/models"
|
||||||
|
"github.com/gogits/gogs/models/errors"
|
||||||
"github.com/gogits/gogs/modules/context"
|
"github.com/gogits/gogs/modules/context"
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
"github.com/gogits/gogs/routers/api/v1/convert"
|
"github.com/gogits/gogs/routers/api/v1/convert"
|
||||||
|
@ -17,7 +18,7 @@ import (
|
||||||
func GetUserByParamsName(ctx *context.APIContext, name string) *models.User {
|
func GetUserByParamsName(ctx *context.APIContext, name string) *models.User {
|
||||||
user, err := models.GetUserByName(ctx.Params(name))
|
user, err := models.GetUserByName(ctx.Params(name))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrUserNotExist(err) {
|
if errors.IsUserNotExist(err) {
|
||||||
ctx.Status(404)
|
ctx.Status(404)
|
||||||
} else {
|
} else {
|
||||||
ctx.Error(500, "GetUserByName", err)
|
ctx.Error(500, "GetUserByName", err)
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
api "github.com/gogits/go-gogs-client"
|
api "github.com/gogits/go-gogs-client"
|
||||||
|
|
||||||
"github.com/gogits/gogs/models"
|
"github.com/gogits/gogs/models"
|
||||||
|
"github.com/gogits/gogs/models/errors"
|
||||||
"github.com/gogits/gogs/modules/context"
|
"github.com/gogits/gogs/modules/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -54,7 +55,7 @@ func Search(ctx *context.APIContext) {
|
||||||
func GetInfo(ctx *context.APIContext) {
|
func GetInfo(ctx *context.APIContext) {
|
||||||
u, err := models.GetUserByName(ctx.Params(":username"))
|
u, err := models.GetUserByName(ctx.Params(":username"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrUserNotExist(err) {
|
if errors.IsUserNotExist(err) {
|
||||||
ctx.Status(404)
|
ctx.Status(404)
|
||||||
} else {
|
} else {
|
||||||
ctx.Error(500, "GetUserByName", err)
|
ctx.Error(500, "GetUserByName", err)
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
log "gopkg.in/clog.v1"
|
log "gopkg.in/clog.v1"
|
||||||
|
|
||||||
"github.com/gogits/gogs/models"
|
"github.com/gogits/gogs/models"
|
||||||
|
"github.com/gogits/gogs/models/errors"
|
||||||
"github.com/gogits/gogs/modules/base"
|
"github.com/gogits/gogs/modules/base"
|
||||||
"github.com/gogits/gogs/modules/context"
|
"github.com/gogits/gogs/modules/context"
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
|
@ -100,7 +101,7 @@ func Invitation(ctx *context.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 models.IsErrUserNotExist(err) {
|
if errors.IsUserNotExist(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 {
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
log "gopkg.in/clog.v1"
|
log "gopkg.in/clog.v1"
|
||||||
|
|
||||||
"github.com/gogits/gogs/models"
|
"github.com/gogits/gogs/models"
|
||||||
|
"github.com/gogits/gogs/models/errors"
|
||||||
"github.com/gogits/gogs/modules/base"
|
"github.com/gogits/gogs/modules/base"
|
||||||
"github.com/gogits/gogs/modules/context"
|
"github.com/gogits/gogs/modules/context"
|
||||||
"github.com/gogits/gogs/modules/form"
|
"github.com/gogits/gogs/modules/form"
|
||||||
|
@ -113,7 +114,7 @@ func SettingsDelete(ctx *context.Context) {
|
||||||
org := ctx.Org.Organization
|
org := ctx.Org.Organization
|
||||||
if ctx.Req.Method == "POST" {
|
if ctx.Req.Method == "POST" {
|
||||||
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 models.IsErrUserNotExist(err) {
|
if errors.IsUserNotExist(err) {
|
||||||
ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_password"), SETTINGS_DELETE, nil)
|
ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_password"), SETTINGS_DELETE, nil)
|
||||||
} else {
|
} else {
|
||||||
ctx.Handle(500, "UserSignIn", err)
|
ctx.Handle(500, "UserSignIn", err)
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
log "gopkg.in/clog.v1"
|
log "gopkg.in/clog.v1"
|
||||||
|
|
||||||
"github.com/gogits/gogs/models"
|
"github.com/gogits/gogs/models"
|
||||||
|
"github.com/gogits/gogs/models/errors"
|
||||||
"github.com/gogits/gogs/modules/base"
|
"github.com/gogits/gogs/modules/base"
|
||||||
"github.com/gogits/gogs/modules/context"
|
"github.com/gogits/gogs/modules/context"
|
||||||
"github.com/gogits/gogs/modules/form"
|
"github.com/gogits/gogs/modules/form"
|
||||||
|
@ -73,7 +74,7 @@ func TeamsAction(ctx *context.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 models.IsErrUserNotExist(err) {
|
if errors.IsUserNotExist(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 {
|
||||||
|
|
|
@ -22,6 +22,7 @@ import (
|
||||||
"gopkg.in/macaron.v1"
|
"gopkg.in/macaron.v1"
|
||||||
|
|
||||||
"github.com/gogits/gogs/models"
|
"github.com/gogits/gogs/models"
|
||||||
|
"github.com/gogits/gogs/models/errors"
|
||||||
"github.com/gogits/gogs/modules/base"
|
"github.com/gogits/gogs/modules/base"
|
||||||
"github.com/gogits/gogs/modules/context"
|
"github.com/gogits/gogs/modules/context"
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
|
@ -59,7 +60,7 @@ func HTTPContexter() macaron.Handler {
|
||||||
|
|
||||||
owner, err := models.GetUserByName(ownerName)
|
owner, err := models.GetUserByName(ownerName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.NotFoundOrServerError("GetUserByName", models.IsErrUserNotExist, err)
|
ctx.NotFoundOrServerError("GetUserByName", errors.IsUserNotExist, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +108,7 @@ func HTTPContexter() macaron.Handler {
|
||||||
}
|
}
|
||||||
|
|
||||||
authUser, err := models.UserSignIn(authUsername, authPassword)
|
authUser, err := models.UserSignIn(authUsername, authPassword)
|
||||||
if err != nil && !models.IsErrUserNotExist(err) {
|
if err != nil && !errors.IsUserNotExist(err) {
|
||||||
ctx.Handle(http.StatusInternalServerError, "UserSignIn", err)
|
ctx.Handle(http.StatusInternalServerError, "UserSignIn", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ import (
|
||||||
"github.com/gogits/git-module"
|
"github.com/gogits/git-module"
|
||||||
|
|
||||||
"github.com/gogits/gogs/models"
|
"github.com/gogits/gogs/models"
|
||||||
|
"github.com/gogits/gogs/models/errors"
|
||||||
"github.com/gogits/gogs/modules/base"
|
"github.com/gogits/gogs/modules/base"
|
||||||
"github.com/gogits/gogs/modules/context"
|
"github.com/gogits/gogs/modules/context"
|
||||||
"github.com/gogits/gogs/modules/form"
|
"github.com/gogits/gogs/modules/form"
|
||||||
|
@ -449,11 +450,7 @@ func ParseCompareInfo(ctx *context.Context) (*models.User, *models.Repository, *
|
||||||
} else if len(headInfos) == 2 {
|
} else if len(headInfos) == 2 {
|
||||||
headUser, err = models.GetUserByName(headInfos[0])
|
headUser, err = models.GetUserByName(headInfos[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrUserNotExist(err) {
|
ctx.NotFoundOrServerError("GetUserByName", errors.IsUserNotExist, err)
|
||||||
ctx.Handle(404, "GetUserByName", nil)
|
|
||||||
} else {
|
|
||||||
ctx.Handle(500, "GetUserByName", err)
|
|
||||||
}
|
|
||||||
return nil, nil, nil, nil, "", ""
|
return nil, nil, nil, nil, "", ""
|
||||||
}
|
}
|
||||||
headBranch = headInfos[1]
|
headBranch = headInfos[1]
|
||||||
|
@ -719,7 +716,7 @@ func CompareAndPullRequestPost(ctx *context.Context, f form.NewIssue) {
|
||||||
func parseOwnerAndRepo(ctx *context.Context) (*models.User, *models.Repository) {
|
func parseOwnerAndRepo(ctx *context.Context) (*models.User, *models.Repository) {
|
||||||
owner, err := models.GetUserByName(ctx.Params(":username"))
|
owner, err := models.GetUserByName(ctx.Params(":username"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.NotFoundOrServerError("GetUserByName", models.IsErrUserNotExist, err)
|
ctx.NotFoundOrServerError("GetUserByName", errors.IsUserNotExist, err)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -753,11 +750,7 @@ func TriggerTask(ctx *context.Context) {
|
||||||
|
|
||||||
pusher, err := models.GetUserByID(pusherID)
|
pusher, err := models.GetUserByID(pusherID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrUserNotExist(err) {
|
ctx.NotFoundOrServerError("GetUserByID", errors.IsUserNotExist, err)
|
||||||
ctx.Error(404)
|
|
||||||
} else {
|
|
||||||
ctx.Handle(500, "GetUserByID", err)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ import (
|
||||||
"github.com/gogits/git-module"
|
"github.com/gogits/git-module"
|
||||||
|
|
||||||
"github.com/gogits/gogs/models"
|
"github.com/gogits/gogs/models"
|
||||||
|
"github.com/gogits/gogs/models/errors"
|
||||||
"github.com/gogits/gogs/modules/base"
|
"github.com/gogits/gogs/modules/base"
|
||||||
"github.com/gogits/gogs/modules/context"
|
"github.com/gogits/gogs/modules/context"
|
||||||
"github.com/gogits/gogs/modules/form"
|
"github.com/gogits/gogs/modules/form"
|
||||||
|
@ -47,7 +48,7 @@ func checkContextUser(ctx *context.Context, uid int64) *models.User {
|
||||||
}
|
}
|
||||||
|
|
||||||
org, err := models.GetUserByID(uid)
|
org, err := models.GetUserByID(uid)
|
||||||
if models.IsErrUserNotExist(err) {
|
if errors.IsUserNotExist(err) {
|
||||||
return ctx.User
|
return ctx.User
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ import (
|
||||||
"github.com/gogits/git-module"
|
"github.com/gogits/git-module"
|
||||||
|
|
||||||
"github.com/gogits/gogs/models"
|
"github.com/gogits/gogs/models"
|
||||||
|
"github.com/gogits/gogs/models/errors"
|
||||||
"github.com/gogits/gogs/modules/base"
|
"github.com/gogits/gogs/modules/base"
|
||||||
"github.com/gogits/gogs/modules/context"
|
"github.com/gogits/gogs/modules/context"
|
||||||
"github.com/gogits/gogs/modules/form"
|
"github.com/gogits/gogs/modules/form"
|
||||||
|
@ -311,7 +312,7 @@ func SettingsCollaborationPost(ctx *context.Context) {
|
||||||
|
|
||||||
u, err := models.GetUserByName(name)
|
u, err := models.GetUserByName(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrUserNotExist(err) {
|
if errors.IsUserNotExist(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 {
|
||||||
|
|
|
@ -6,7 +6,6 @@ package repo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -16,6 +15,7 @@ import (
|
||||||
api "github.com/gogits/go-gogs-client"
|
api "github.com/gogits/go-gogs-client"
|
||||||
|
|
||||||
"github.com/gogits/gogs/models"
|
"github.com/gogits/gogs/models"
|
||||||
|
"github.com/gogits/gogs/models/errors"
|
||||||
"github.com/gogits/gogs/modules/base"
|
"github.com/gogits/gogs/modules/base"
|
||||||
"github.com/gogits/gogs/modules/context"
|
"github.com/gogits/gogs/modules/context"
|
||||||
"github.com/gogits/gogs/modules/form"
|
"github.com/gogits/gogs/modules/form"
|
||||||
|
@ -468,7 +468,7 @@ func TestWebhook(ctx *context.Context) {
|
||||||
author, err := models.GetUserByEmail(commit.Author.Email)
|
author, err := models.GetUserByEmail(commit.Author.Email)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
authorUsername = author.Name
|
authorUsername = author.Name
|
||||||
} else if !models.IsErrUserNotExist(err) {
|
} else if !errors.IsUserNotExist(err) {
|
||||||
ctx.Flash.Error(fmt.Sprintf("GetUserByEmail.(author) [%s]: %v", commit.Author.Email, err))
|
ctx.Flash.Error(fmt.Sprintf("GetUserByEmail.(author) [%s]: %v", commit.Author.Email, err))
|
||||||
ctx.Status(500)
|
ctx.Status(500)
|
||||||
return
|
return
|
||||||
|
@ -477,7 +477,7 @@ func TestWebhook(ctx *context.Context) {
|
||||||
committer, err := models.GetUserByEmail(commit.Committer.Email)
|
committer, err := models.GetUserByEmail(commit.Committer.Email)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
committerUsername = committer.Name
|
committerUsername = committer.Name
|
||||||
} else if !models.IsErrUserNotExist(err) {
|
} else if !errors.IsUserNotExist(err) {
|
||||||
ctx.Flash.Error(fmt.Sprintf("GetUserByEmail.(committer) [%s]: %v", commit.Committer.Email, err))
|
ctx.Flash.Error(fmt.Sprintf("GetUserByEmail.(committer) [%s]: %v", commit.Committer.Email, err))
|
||||||
ctx.Status(500)
|
ctx.Status(500)
|
||||||
return
|
return
|
||||||
|
|
|
@ -12,6 +12,7 @@ import (
|
||||||
log "gopkg.in/clog.v1"
|
log "gopkg.in/clog.v1"
|
||||||
|
|
||||||
"github.com/gogits/gogs/models"
|
"github.com/gogits/gogs/models"
|
||||||
|
"github.com/gogits/gogs/models/errors"
|
||||||
"github.com/gogits/gogs/modules/base"
|
"github.com/gogits/gogs/modules/base"
|
||||||
"github.com/gogits/gogs/modules/context"
|
"github.com/gogits/gogs/modules/context"
|
||||||
"github.com/gogits/gogs/modules/form"
|
"github.com/gogits/gogs/modules/form"
|
||||||
|
@ -49,7 +50,7 @@ func AutoSignIn(ctx *context.Context) (bool, error) {
|
||||||
|
|
||||||
u, err := models.GetUserByName(uname)
|
u, err := models.GetUserByName(uname)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !models.IsErrUserNotExist(err) {
|
if !errors.IsUserNotExist(err) {
|
||||||
return false, fmt.Errorf("GetUserByName: %v", err)
|
return false, fmt.Errorf("GetUserByName: %v", err)
|
||||||
}
|
}
|
||||||
return false, nil
|
return false, nil
|
||||||
|
@ -113,7 +114,7 @@ func SignInPost(ctx *context.Context, f form.SignIn) {
|
||||||
|
|
||||||
u, err := models.UserSignIn(f.UserName, f.Password)
|
u, err := models.UserSignIn(f.UserName, f.Password)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrUserNotExist(err) {
|
if errors.IsUserNotExist(err) {
|
||||||
ctx.RenderWithErr(ctx.Tr("form.username_password_incorrect"), SIGNIN, &f)
|
ctx.RenderWithErr(ctx.Tr("form.username_password_incorrect"), SIGNIN, &f)
|
||||||
} else {
|
} else {
|
||||||
ctx.Handle(500, "UserSignIn", err)
|
ctx.Handle(500, "UserSignIn", err)
|
||||||
|
@ -286,11 +287,7 @@ func Activate(ctx *context.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := models.UpdateUser(user); err != nil {
|
if err := models.UpdateUser(user); err != nil {
|
||||||
if models.IsErrUserNotExist(err) {
|
ctx.Handle(500, "UpdateUser", err)
|
||||||
ctx.Error(404)
|
|
||||||
} else {
|
|
||||||
ctx.Handle(500, "UpdateUser", err)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -351,7 +348,7 @@ func ForgotPasswdPost(ctx *context.Context) {
|
||||||
|
|
||||||
u, err := models.GetUserByEmail(email)
|
u, err := models.GetUserByEmail(email)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrUserNotExist(err) {
|
if errors.IsUserNotExist(err) {
|
||||||
ctx.Data["Hours"] = setting.Service.ActiveCodeLives / 60
|
ctx.Data["Hours"] = setting.Service.ActiveCodeLives / 60
|
||||||
ctx.Data["IsResetSent"] = true
|
ctx.Data["IsResetSent"] = true
|
||||||
ctx.HTML(200, FORGOT_PASSWORD)
|
ctx.HTML(200, FORGOT_PASSWORD)
|
||||||
|
|
|
@ -12,6 +12,7 @@ import (
|
||||||
"github.com/Unknwon/paginater"
|
"github.com/Unknwon/paginater"
|
||||||
|
|
||||||
"github.com/gogits/gogs/models"
|
"github.com/gogits/gogs/models"
|
||||||
|
"github.com/gogits/gogs/models/errors"
|
||||||
"github.com/gogits/gogs/modules/base"
|
"github.com/gogits/gogs/modules/base"
|
||||||
"github.com/gogits/gogs/modules/context"
|
"github.com/gogits/gogs/modules/context"
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
|
@ -32,11 +33,7 @@ func getDashboardContextUser(ctx *context.Context) *models.User {
|
||||||
// Organization.
|
// Organization.
|
||||||
org, err := models.GetUserByName(orgName)
|
org, err := models.GetUserByName(orgName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrUserNotExist(err) {
|
ctx.NotFoundOrServerError("GetUserByName", errors.IsUserNotExist, err)
|
||||||
ctx.Handle(404, "GetUserByName", err)
|
|
||||||
} else {
|
|
||||||
ctx.Handle(500, "GetUserByName", err)
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
ctxUser = org
|
ctxUser = org
|
||||||
|
@ -71,7 +68,7 @@ func retrieveFeeds(ctx *context.Context, ctxUser *models.User, userID, offset in
|
||||||
if !ok {
|
if !ok {
|
||||||
u, err := models.GetUserByName(act.ActUserName)
|
u, err := models.GetUserByName(act.ActUserName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrUserNotExist(err) {
|
if errors.IsUserNotExist(err) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
ctx.Handle(500, "GetUserByName", err)
|
ctx.Handle(500, "GetUserByName", err)
|
||||||
|
@ -406,11 +403,7 @@ func showOrgProfile(ctx *context.Context) {
|
||||||
func Email2User(ctx *context.Context) {
|
func Email2User(ctx *context.Context) {
|
||||||
u, err := models.GetUserByEmail(ctx.Query("email"))
|
u, err := models.GetUserByEmail(ctx.Query("email"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrUserNotExist(err) {
|
ctx.NotFoundOrServerError("GetUserByEmail", errors.IsUserNotExist, err)
|
||||||
ctx.Handle(404, "GetUserByEmail", err)
|
|
||||||
} else {
|
|
||||||
ctx.Handle(500, "GetUserByEmail", err)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctx.Redirect(setting.AppSubUrl + "/user/" + u.Name)
|
ctx.Redirect(setting.AppSubUrl + "/user/" + u.Name)
|
||||||
|
|
|
@ -12,6 +12,7 @@ import (
|
||||||
"github.com/Unknwon/paginater"
|
"github.com/Unknwon/paginater"
|
||||||
|
|
||||||
"github.com/gogits/gogs/models"
|
"github.com/gogits/gogs/models"
|
||||||
|
"github.com/gogits/gogs/models/errors"
|
||||||
"github.com/gogits/gogs/modules/base"
|
"github.com/gogits/gogs/modules/base"
|
||||||
"github.com/gogits/gogs/modules/context"
|
"github.com/gogits/gogs/modules/context"
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
|
@ -26,11 +27,7 @@ const (
|
||||||
func GetUserByName(ctx *context.Context, name string) *models.User {
|
func GetUserByName(ctx *context.Context, name string) *models.User {
|
||||||
user, err := models.GetUserByName(name)
|
user, err := models.GetUserByName(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrUserNotExist(err) {
|
ctx.NotFoundOrServerError("GetUserByName", errors.IsUserNotExist, err)
|
||||||
ctx.Handle(404, "GetUserByName", nil)
|
|
||||||
} else {
|
|
||||||
ctx.Handle(500, "GetUserByName", err)
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return user
|
return user
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
package user
|
package user
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -14,6 +13,7 @@ import (
|
||||||
log "gopkg.in/clog.v1"
|
log "gopkg.in/clog.v1"
|
||||||
|
|
||||||
"github.com/gogits/gogs/models"
|
"github.com/gogits/gogs/models"
|
||||||
|
"github.com/gogits/gogs/models/errors"
|
||||||
"github.com/gogits/gogs/modules/base"
|
"github.com/gogits/gogs/modules/base"
|
||||||
"github.com/gogits/gogs/modules/context"
|
"github.com/gogits/gogs/modules/context"
|
||||||
"github.com/gogits/gogs/modules/form"
|
"github.com/gogits/gogs/modules/form"
|
||||||
|
@ -456,7 +456,7 @@ func SettingsDelete(ctx *context.Context) {
|
||||||
|
|
||||||
if ctx.Req.Method == "POST" {
|
if ctx.Req.Method == "POST" {
|
||||||
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 models.IsErrUserNotExist(err) {
|
if errors.IsUserNotExist(err) {
|
||||||
ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_password"), SETTINGS_DELETE, nil)
|
ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_password"), SETTINGS_DELETE, nil)
|
||||||
} else {
|
} else {
|
||||||
ctx.Handle(500, "UserSignIn", err)
|
ctx.Handle(500, "UserSignIn", err)
|
||||||
|
|
Loading…
Reference in New Issue