satellite/console: only create user with registration token
we should only allow new user to register with a registration token Change-Id: Iea579976f1e7aa98799693a90401b31a7915bb22
This commit is contained in:
parent
2ae9978304
commit
f9189f8d94
@ -387,25 +387,14 @@ func (s *Service) CreateUser(ctx context.Context, user CreateUser, tokenSecret R
|
||||
}
|
||||
|
||||
// TODO: remove after vanguard release
|
||||
// when user uses an open source partner referral link, there won't be a registration token in the link.
|
||||
// therefore, we need to create one so we can still control the project limit on the account level
|
||||
var registrationToken *RegistrationToken
|
||||
if user.PartnerID != "" {
|
||||
// set the project limit to be 1 for open source partner invitees
|
||||
registrationToken, err = s.store.RegistrationTokens().Create(ctx, 1)
|
||||
if err != nil {
|
||||
return nil, Error.Wrap(err)
|
||||
}
|
||||
} else {
|
||||
registrationToken, err = s.store.RegistrationTokens().GetBySecret(ctx, tokenSecret)
|
||||
if err != nil {
|
||||
return nil, ErrUnauthorized.Wrap(err)
|
||||
}
|
||||
// if a registration token is already associated with an user ID, that means the token is already used
|
||||
// we should terminate the account creation process and return an error
|
||||
if registrationToken.OwnerID != nil {
|
||||
return nil, errs.New(usedRegTokenVanguardErrMsg)
|
||||
}
|
||||
registrationToken, err := s.store.RegistrationTokens().GetBySecret(ctx, tokenSecret)
|
||||
if err != nil {
|
||||
return nil, ErrUnauthorized.Wrap(err)
|
||||
}
|
||||
// if a registration token is already associated with an user ID, that means the token is already used
|
||||
// we should terminate the account creation process and return an error
|
||||
if registrationToken.OwnerID != nil {
|
||||
return nil, errs.New(usedRegTokenVanguardErrMsg)
|
||||
}
|
||||
|
||||
u, err = s.store.Users().GetByEmail(ctx, user.Email)
|
||||
|
Loading…
Reference in New Issue
Block a user