use of net.vidageek.mirror.dsl.Mirror in project mamute by caelum.
the class RulesInterceptor method intercept.
@Override
public void intercept(InterceptorStack stack, ControllerMethod method, Object obj) throws InterceptionException {
ClassController<KarmaCalculator> mirrorOnKarma = new Mirror().on(KarmaCalculator.class);
List<Field> karmaCalculatorFields = mirrorOnKarma.reflectAll().fields();
for (Field field : karmaCalculatorFields) {
result.include(field.getName(), mirrorOnKarma.get().field(field));
}
PermissionRules[] rules = PermissionRules.values();
for (PermissionRules rule : rules) {
long karma = environmentKarma.get(rule);
result.include(rule.name(), karma);
}
stack.next(method, obj);
}
use of net.vidageek.mirror.dsl.Mirror in project mamute by caelum.
the class UserDAOTest method should_search_by_email_and_legacy_password_and_update_password.
@Test
public void should_search_by_email_and_legacy_password_and_update_password() {
String password = "654321";
User gui = user("Guilherme Sonar", "gui@email.com.br");
LoginMethod brutalLogin = LoginMethod.brutalLogin(gui, "gui@email.com.br", password);
new Mirror().on(brutalLogin).set().field("token").withValue(MD5.crypt(password));
gui.add(brutalLogin);
users.save(gui);
session.save(brutalLogin);
assertNull(users.findByMailAndPassword("gui@email.com.br", password));
User found = users.findByMailAndLegacyPasswordAndUpdatePassword("gui@email.com.br", password);
assertEquals(gui, found);
assertEquals(Digester.encrypt(password), found.getBrutalLogin().getToken());
assertNull(users.findByMailAndPassword("joao.silveira@email.com.br", password));
assertNull(users.findByMailAndPassword("gui@email.com.br", "123456"));
}
Aggregations