auth.add(new Authority(role.getName()));
}
user.registerLogin();
userDAO.upsert(user);
AuditLog auditLog = new AuditLog();
auditLog.setMessage("User logged in");
auditLog.setUser(user.getUsername());
auditLog.setType(AuditLogType.LOGIN);
auditLogDAO.upsert(auditLog);
LOG.info(format("User %s successfully logged in with roles [%s]", username, auth));
return new UsernamePasswordAuthenticationToken(user.getUsername(), user.getPassword(), auth);
}