예제 #1
0
 /// <summary>
 /// Adds user to role
 /// </summary>
 /// <param name="role"></param>
 /// <param name="user"></param>
 public void AddUserToRole(Role role, User user)
 {
     if (!role.Users.Contains(user))
     {
         role.Users.Add(user);
         AddRoleToUser(user, role);
     }
 }
예제 #2
0
 /// <summary>
 /// Adds role to user
 /// </summary>
 /// <param name="user"></param>
 /// <param name="role"></param>
 public virtual void AddRoleToUser(User user, Role role)
 {
     if (!user.Roles.Contains(role))
     {
         user.Roles.Add(role);
         AddUserToRole(role, user);
     }
 }
예제 #3
0
 /// <summary>
 /// Updates user
 /// </summary>
 /// <param name="user"></param>
 public void UpdateUser(User user)
 {
     _context.Save(user);
 }
예제 #4
0
 /// <summary>
 /// Base constructor, which initializes BaseService(News)
 /// </summary>
 /// <param name="username"></param>
 /// <param name="email"></param>
 /// <param name="password"></param>
 /// <param name="status"></param>
 /// <returns></returns>
 public User RegisterUser(string username, string email, string password, out RegisterStatus status)
 {
     var passwordSalt = _passwordMethodsProvider.CreateSalt();
     var newUser = new User
     {
         Login = username,
         CreatedDate = DateTime.Now,
         PasswordSalt = passwordSalt,
         Password = _passwordMethodsProvider.CreatePasswordHash(password, passwordSalt),
         Email = email,
         IsActivated = true,
         IsLockedOut = false,
         LastLockedOutDate = null,
         LastLoginDate = null,
     };
     _context.Add(newUser);
     status = RegisterStatus.Success;
     return newUser;
 }