public IActionResult CreateAccount(UserViewModel uvm)
        {
            if (ModelState.IsValid)
            {
                _user = ViewModelConverter.ConvertViewModelToUser(uvm);
                IUser configuredUser = _accountManager.ConfigureAccount(_user);
                if (configuredUser != null)
                {
                    _userCollection.Add(_user);
                    return(RedirectToAction("Login"));
                }
            }

            return(RedirectToAction("Register"));
        }
 public IActionResult OnPost()
 {
     if (ModelState.IsValid)
     {
         User user = new User()
         {
             Id        = ObjectId.GenerateNewId().ToString(),
             FirstName = Context.FirstName,
             LastName  = Context.LastName,
             Email     = Context.Email,
             Password  = Context.Password,
             IsAdmin   = false
         };
         userList.Add(user);
         return(RedirectToPage("Home", new { userId = user.Id }));
     }
     return(Page());
 }
        public async Task <User> CreateUserAccount(CreateUserAccountCredentials credentials)
        {
            var salt     = WebrewHasher.Instance.GetRandomSalt(32);
            var hashword = WebrewHasher.Instance.HashPassword(credentials.Password, SecuritySettings.PasswordHashSecret, salt);

            var account = await AccountCollection.Add(new Account
            {
                Email    = credentials.Email,
                Password = hashword,
                Username = credentials.Username,
                Salt     = Encoding.UTF8.GetString(salt)
            });;

            var user = await UserCollection.Add(new User
            {
                AccountId = account.Id,
                Email     = credentials.Email,
                Username  = credentials.Username
            });

            return(user);
        }
示例#4
0
 public void AddUser(ChannelUser user)
 {
     users.Add(user.IRCUser.Name, user);
     UserAdded?.Invoke(this, new ChannelUserEventArgs(user));
 }
示例#5
0
 public Task <bool> AddUser(User user)
 {
     return(_userCollection.Add(user));
 }