Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion internal/features/auth/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func (s *Service) Register(input RegisterInput) (*RegisterResult, error) {
// Registration targets the new user's own database, which would disconnect
// any active session. Refuse while signed in.
if s.session != nil {
return nil, errors.ErrInvalidInput
return nil, errors.ErrAlreadySignedIn
}

// Reject usernames already taken on this machine: every registered account
Expand Down Expand Up @@ -303,6 +303,12 @@ func (s *Service) Login(input LoginInput) (bool, error) {
return false, errors.ErrInvalidInput
}

// Login targets the (potential) new user's own database, which would
// disconnect any active session. Refuse while signed in.
if s.session != nil {
return false, errors.ErrAlreadySignedIn
}

passwordBytes := []byte(input.Password)
defer crypto.Wipe(passwordBytes)

Expand Down
6 changes: 6 additions & 0 deletions internal/shared/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ var (
"you must be logged in to access this resource",
)

// ErrAlreadySignedIn means a sign-in was attempted while a session is
// already active. Callers must sign out before signing in as another user.
ErrAlreadySignedIn = errors.New(
"you are already signed in. Please sign out before signing in as another user",
)

// ErrJobNotFound means the requested queue entry does not exist.
ErrJobNotFound = errors.New(
"the file entry you are looking for no longer exists",
Expand Down
Loading