Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new user types reserved, bot, and remote #24026

Merged
merged 11 commits into from
Apr 17, 2023
4 changes: 3 additions & 1 deletion models/user/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ func GetUserFollowers(ctx context.Context, u, viewer *User, listOptions db.ListO
Select("`user`.*").
Join("LEFT", "follow", "`user`.id=follow.user_id").
Where("follow.follow_id=?", u.ID).
And("`user`.type=?", UserTypeIndividual).
And(isUserVisibleToViewerCond(viewer))

if listOptions.Page != 0 {
Expand All @@ -336,6 +337,7 @@ func GetUserFollowing(ctx context.Context, u, viewer *User, listOptions db.ListO
Select("`user`.*").
Join("LEFT", "follow", "`user`.id=follow.follow_id").
Where("follow.user_id=?", u.ID).
And("`user`.type=?", UserTypeIndividual).
And(isUserVisibleToViewerCond(viewer))

if listOptions.Page != 0 {
Expand Down Expand Up @@ -961,7 +963,7 @@ func GetUserByName(ctx context.Context, name string) (*User, error) {
if len(name) == 0 {
return nil, ErrUserNotExist{0, name, 0}
}
u := &User{LowerName: strings.ToLower(name)}
u := &User{LowerName: strings.ToLower(name), Type: UserTypeIndividual}
has, err := db.GetEngine(ctx).Get(u)
if err != nil {
return nil, err
Expand Down
8 changes: 8 additions & 0 deletions services/auth/source/db/authenticate.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,13 @@ func Authenticate(user *user_model.User, login, password string) (*user_model.Us
}
}

// attempting to login as a non-user account
if user.Type != 0 {
techknowlogick marked this conversation as resolved.
Show resolved Hide resolved
return nil, user_model.ErrUserProhibitLogin{
UID: user.ID,
Name: user.Name,
}
}

return user, nil
}