Пример #1
0
        public async Task <AuthenticationResult> RegisterUserAsync(string email, string password)
        {
            if (await UserExistsByEmailAsync(email))
            {
                return(AuthFailed("User already exists"));
            }

            var user = new User {
                Email = email, Password = password, RoleId = "user"
            };

            if (!await AddUserAsync(user))
            {
                return(AuthFailed("Something went wrong"));
            }

            return(await _jwtManager.AuthenticateUserAsync(user));
        }