use of org.mamute.model.User in project mamute by caelum.
the class InputRule method isAllowed.
public boolean isAllowed() {
if (!env.supports("feature.input.rule"))
return true;
User current = user.getCurrent();
boolean isAllowed = input.can(current);
if (isAllowed)
input.ping(current);
return isAllowed;
}
use of org.mamute.model.User in project mamute by caelum.
the class DaoManager method randomUser.
public User randomUser() {
this.session.beginTransaction();
String email = String.format("acceptance%d@brutal.com", randomizer.nextLong());
User user = new User(SanitizedText.fromTrustedText("Acceptance Test User"), email);
LoginMethod brutalLogin = LoginMethod.brutalLogin(user, email, "123456");
user.add(brutalLogin);
this.userDao.save(user);
this.loginMethodDao.save(brutalLogin);
this.session.getTransaction().commit();
return user;
}
use of org.mamute.model.User in project mamute by caelum.
the class LDAPAuthenticator method authenticate.
public boolean authenticate(String username, String password) {
// auth credentials
if (!ldap.authenticate(username, password)) {
return false;
}
String email = ldap.getEmail(username);
User retrieved = users.findByEmail(email);
if (retrieved == null) {
retrieved = users.findByMailAndLegacyPasswordAndUpdatePassword(email, password);
}
if (retrieved == null) {
return false;
}
system.login(retrieved);
return true;
}
use of org.mamute.model.User in project mamute by caelum.
the class CommentQuestionTest method login.
@Before
public void login() {
DaoManager manager = new DaoManager();
User author = manager.randomUser();
manager.createQuestion(author);
}
use of org.mamute.model.User in project mamute by caelum.
the class VoteUpDownTest method login.
@Before
public void login() {
DaoManager manager = new DaoManager();
User author = manager.randomUser();
Question question = manager.createQuestion(author);
manager.answerQuestion(author, question);
loginWithALotOfKarma();
questionPage = home().toFirstQuestionPage();
}
Aggregations