Exemplo n.º 1
0
 public bool AddUser(UserData user)
 {
     if(users.Any(x=>x.Username==user.Username))
     {
         return false;
     }
     users.Add(user);
     user.UniqueID=(unique++).ToString();
     return true;
 }
Exemplo n.º 2
0
 public bool UpdateUserByID(UserData user)
 {
     foreach(var u in users)
     {
         if(u.UniqueID==user.UniqueID)
         {
             u.PasswordHash=user.PasswordHash;
             u.Salt=user.Salt;
             u.Username=user.Username;
             u.Groups=user.Groups;
             u.EmailAddress=user.EmailAddress;
             return true;
         }
     }
     return false;
 }
Exemplo n.º 3
0
 public bool DeleteUserByID(UserData user)
 {
     UserData del=null;
     foreach(var u in users)
     {
         if(u.UniqueID==user.UniqueID)
         {
             del=u;
             break;
         }
     }
     if(del==null)
     {
         return false;
     }
     users.Remove(del);
     return true;
 }
Exemplo n.º 4
0
 /// <summary>
 /// This will reset the password of a user.
 /// </summary>
 /// <param name="user">
 /// </param>
 /// <returns>
 /// The generated password
 /// </returns>
 public static string ResetPassword(this IAuthMechanism auth, UserData user)
 {
     string pass=Membership.GeneratePassword(8,2);
     auth.ComputePasswordHash(user,pass);
     if(!auth.UserStore.UpdateUserByID(user)){
         throw new ApplicationException("User could not be updated");
     }
     return pass;
 }