Skip to content

Commit

Permalink
🐛 Fix activate user route
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinbreiz committed Sep 18, 2023
1 parent 3457e21 commit 0392ad8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/invitation/invitation.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export class InvitationRepository {
findByToken = (token: string) =>
this.model.findOne({ activationToken: token }).orFail(new RpcException('INVITATION_NOT_FOUND')).exec();

markUsed = (token: string): Promise<InvitationDocument> =>
this.model.findByIdAndUpdate(token, { used: true }).orFail(new RpcException('INVITATION_NOT_FOUND')).exec();
markUsed = async (token: string): Promise<InvitationDocument> => {
const invitation = await this.findByToken(token);
invitation.used = true;
return invitation.save();
};
}
6 changes: 5 additions & 1 deletion src/user/_utils/user.proto
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,18 @@ message GetUsersResponse {
repeated string users = 1;
}

message ActivateUserRequest {
string token = 1;
}

// The UserService defines the methods that our service exposes
service User {
rpc SignIn(SignInSignUpRequest) returns (UserResponse);
rpc SignUp(SignInSignUpRequest) returns (UserResponse);
rpc ResetPassword(PasswordRequest) returns (EmptyResponse);
rpc ChangeEmail(EmailRequest) returns (EmptyResponse);
rpc InviteUser(InviteUserRequest) returns (EmptyResponse);
rpc ActivateUser(EmptyRequest) returns (EmptyResponse);
rpc ActivateUser(ActivateUserRequest) returns (EmptyResponse);
rpc ChangeRights(ChangeRightsRequest) returns (EmptyResponse);
rpc GetUsers(EmptyRequest) returns (GetUsersResponse);
rpc DeleteUser(EmailRequest) returns (EmptyResponse);
Expand Down

0 comments on commit 0392ad8

Please sign in to comment.