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; }
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; }
public void InsertUser(User user) { _repository.Insert(user); _repository.Save(); }