public async Task <UserDto> ApiRegister([FromBody] UserDto userInfo) { // if no users, the first one made is always admin if (userService.Get().Count() == 0) { userInfo.Role = "Admin"; } else { userInfo.Role = "Normal"; } LoginDto smallerDto = new LoginDto() { UserName = userInfo.Name, Password = userInfo.PasswordOrHash }; CreatedLoginDto preregisterInfo = loginService.RegisterOrUpdate(smallerDto); // this is just hashing the password and should always succeed var result = userService.Create(userInfo.CloneWithNewInfo(preregisterInfo)); // register implies Login(user) if no one is currently logged in if (ApiGetCurrentUser() == null) { await ApiLogin(smallerDto); } return(result); }