Created
March 2, 2018 10:25
-
-
Save mczachurski/b7febd30b5980925bad048d5d20e74a8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public func add(entity: User) throws { | |
entity.salt = String(randomWithLength: 14) | |
entity.password = try entity.password.generateHash(salt: entity.salt) | |
if let errors = self.userValidator.getValidationErrors(entity) { | |
throw ValidationsError(errors: errors) | |
} | |
try self.usersRepository.add(entity: entity) | |
try self.userRolesRepository.set(roles: entity.roles, forUserId: entity.id) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment