public async Task Add(CityHall cityHall) { if (!ExecuteValidation(new CityHallValidation(), cityHall)) { return; } bool userExists = await _userService.FirebaseUserExistsByEmail(cityHall.Email); if (userExists) { Notify("Endereço de e-mail já cadastrado no sistema."); return; } await _repository.Add(cityHall); CityHall newCityHall = await _repository.GetById(cityHall.Id); if (newCityHall != null) { UserRecordArgs args = new UserRecordArgs() { DisplayName = newCityHall.Name, Email = newCityHall.Email, Password = newCityHall.CNPJ }; UserRecord fbUser = await _firebaseAuth.CreateUserAsync(args); if (fbUser != null) { User newUser = new User() { FirebaseUserId = fbUser.Uid, Email = fbUser.Email, CreationDate = DateTime.Now, FirstName = fbUser.DisplayName, CityHallId = newCityHall.Id }; await _userService.Add(newUser); // await _relationHandler.UpdateRelationAsync(newUser.Id, newCityHall.Id, true); var claims = new Dictionary <string, object>() { { "app_user_id", newUser.Id }, { "user", true }, { "city_hall", true } }; await _roleService.UpdateUserRole("user", newUser.Id, true); await _roleService.UpdateUserRole("city_hall", newUser.Id, true); await _roleService.UpdateUserClaims(newUser.Id, claims); } } }
public async Task <AppUserDto> CreateUserAsync(AppUserDto dto) { var userRecord = await _firebaseAuth.CreateUserAsync(new UserRecordArgs { Email = dto.Email, Password = dto.Password, }); dto.Uid = userRecord.Uid; return(dto); }
public async Task <string> CreateUserWithUsernameAndPasswordAsync(string username, string password) { try { var userRecord = await _auth.CreateUserAsync(new UserRecordArgs { Email = username, Password = password }).ConfigureAwait(false); return(userRecord.Uid); } catch (Exception) { throw new UserAlreadyExistsException(); } }
public async Task <UserRecord> RegisterUser(UserRecordArgs args) { return(await firebaseAuth.CreateUserAsync(args)); }