コード例 #1
0
        public IActionResult Registration(RegistrationCredential registrationCred)
        {
            User loginningUserName         = _sqlUserHandler.GetUser(registrationCred.UserName);
            bool isLoginningUserEmailTaken = _sqlUserHandler.GetUsers().Any(x => x.Email == registrationCred.Email);

            if (loginningUserName != null || isLoginningUserEmailTaken)
            {
                return(BadRequest("username or email already taken"));
            }

            Address userAddress = new Address(registrationCred.City, registrationCred.Street, registrationCred.HouseNumber, registrationCred.PostCode);
            User    user        = new User(registrationCred.UserName, registrationCred.Email, userAddress, registrationCred.Password); // we should validate the password as well if it strong enough

            _sqlUserHandler.AddUser(user);
            return(Ok("successful registration"));
        }
コード例 #2
0
 public List <FireChatCore.User> GetUsers()
 {
     return(repository.GetUsers());
 }