public async Task <Response> ApplyInvite(Guid userId, Guid entityId, InviteEntityType entityType) { var user = await _usersProvider.GetById(userId); switch (entityType) { case InviteEntityType.Company: await AddUserToCompany(entityId, userId, MembershipStatus.Member); break; case InviteEntityType.Team: await AddUserToTeam(entityId, userId, MembershipStatus.Member); break; case InviteEntityType.Project: await AddUserToProject(entityId, userId, MembershipStatus.Member); break; default: throw new ArgumentOutOfRangeException(nameof(entityType), entityType, null); } await _invitesService.RemoveInvite(user.Data.Email, entityId, entityType); return(new Response()); }
public async Task <Response> SetPassword(UserSetPasswordDTO dto, ClaimsPrincipal claims) { var userResponse = await _provider.GetById(claims.GetUserId()); if (!userResponse.IsSuccess) { return(userResponse); } var oldPasswordCorrectResponse = await _tokensService.Authenticate(new CredentialsDTO { Email = userResponse.Data.Email, Password = dto.OldPassword }); if (!oldPasswordCorrectResponse.IsSuccess) { return(oldPasswordCorrectResponse); } return(await _service.SetPassword(userResponse.Data.Email, dto.Password)); }
private async Task <UserStatus> GetUserStatus(ClaimsPrincipal claims) { var userId = claims.GetUserId(); var userResponse = await _usersProvider.GetById(userId); if (userResponse.IsSuccess) { if (userResponse.Data != null) { return(userResponse.Data.Status); } } return(UserStatus.Blocked); }
public async Task <Response <UserDTO> > GetCurrentUser(ClaimsPrincipal claims) { var result = await _provider.GetById(claims.GetUserId()); return(result); }