Skip to content

Instantly share code, notes, and snippets.

@mczachurski
Created March 2, 2018 10:25
Show Gist options
  • Save mczachurski/b7febd30b5980925bad048d5d20e74a8 to your computer and use it in GitHub Desktop.
Save mczachurski/b7febd30b5980925bad048d5d20e74a8 to your computer and use it in GitHub Desktop.
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