Пример #1
0
 public User Login(User model)
 {
     var user = GetUserByEmail(model.Email);
     if (user == null)
         throw new UserNotFoundException();
     if (!CryptService
         .GetMd5(model.Password + user.Salt)
         .Equals(user.Password))
         throw new UserNotFoundException();
     return user;
 }
Пример #2
0
 public User Register(User user)
 {
     if (user.Email == null || user.Name == null || user.Password == null)
         throw new BadModelException();
     if (GetUserByEmail(user.Email) != null)
     {
         throw new UserAlreadyExistsException();
     }
     user.Salt = CryptService.GetRandomSalt();
     user.Password = CryptService.GetMd5(user.Password + user.Salt);
     user.Roles = Roles.User;
     InsertUser(user);
     return user;
 }
Пример #3
0
 public void InsertUser(User user)
 {
     _repository.Insert(user);
     _repository.Save();
 }