Example #1
0
        public User CreateUser(User user)
        {
            if (_storage.IsEmailAlreadyExists(user.Email))
            {
                throw new EmailAlreadyExistsException();
            }

            user.Id            = Guid.NewGuid();
            user.CreatedOn     = DateTime.UtcNow;
            user.LastUpdatedOn = DateTime.UtcNow;
            user.LastLoginOn   = DateTime.UtcNow;
            user.Token         = _identityService.GetToken(user.Email, user.Password);
            user.Password      = _passwordHashService.GetHashedPassword(user.Password);
            _storage.Create(user);
            return(user);
        }