use of org.mamute.model.User in project mamute by caelum.
the class QuestionRssEntryFactory method writeEntry.
public void writeEntry(RssContent rssContent, OutputStream output) {
User author = rssContent.getAuthor();
RssImageEntry imageEntry = new RssImageEntryBuilder().withUrl(author.getSmallPhoto(gravatarUrl)).build();
RssEntry entry = new RssEntryBuilder().withAuthor(author.getName()).withTitle(rssContent.getTitle()).withLink(home + rssContent.getLinkPath()).withId(rssContent.getId().toString()).withDate(rssContent.getCreatedAt()).withImage(imageEntry).build();
XStream xstream = buildXstream();
xstream.processAnnotations(RssEntry.class);
xstream.toXML(entry, output);
}
use of org.mamute.model.User in project mamute by caelum.
the class LoginMethodManager method createNewUser.
private void createNewUser(String rawToken, SignupInfo signupInfo, MethodType type) {
User user = new User(fromTrustedText(signupInfo.getName()), signupInfo.getEmail());
LoginMethod googleLogin = new LoginMethod(type, signupInfo.getEmail(), rawToken, user);
if (signupInfo.containsPhotoUrl()) {
user.setPhotoUri(signupInfo.getPhotoUri());
}
user.add(googleLogin);
users.save(user);
loginMethods.save(googleLogin);
access.login(user);
}
use of org.mamute.model.User in project mamute by caelum.
the class LoginMethodManager method merge.
public boolean merge(MethodType type, SocialAPI socialApi) {
Optional<SignupInfo> optional = socialApi.getSignupInfo();
if (!optional.isPresent())
return false;
SignupInfo signupInfo = optional.get();
User existantGoogleUser = users.findByEmailAndMethod(signupInfo.getEmail(), type);
if (existantGoogleUser != null) {
access.login(existantGoogleUser);
return true;
}
String token = socialApi.getAccessToken().getToken();
User existantUser = users.findByEmail(signupInfo.getEmail());
if (existantUser != null) {
mergeLoginMethod.mergeLoginMethods(token, existantUser, type);
return true;
}
createNewUser(token, signupInfo, type);
return true;
}
use of org.mamute.model.User in project mamute by caelum.
the class NewsController method newNews.
@Post
@CustomBrutauthRules({ LoggedRule.class, InputRule.class })
public void newNews(String title, MarkedText description) {
NewsInformation information = new NewsInformation(title, description, currentUser, "new news");
User author = currentUser.getCurrent();
News news = new News(information, author);
result.include("news", news);
newses.save(news);
result.redirectTo(this).showNews(news, news.getSluggedTitle());
}
use of org.mamute.model.User in project mamute by caelum.
the class ForgotPasswordController method requestEmailWithToken.
@Post
public void requestEmailWithToken(String email) {
User user = users.loadByEmail(email);
if (user == null) {
validator.add(messageFactory.build("error", "forgot_password.invalid_email"));
validator.onErrorRedirectTo(this).forgotPasswordForm();
return;
}
Email forgotPasswordEmail = emailWithTokenFor(user);
try {
mailer.send(forgotPasswordEmail);
result.include("mamuteMessages", Arrays.asList(messageFactory.build("confirmation", "forgot_password.sent_mail", user.getEmail()), messageFactory.build("confirmation", "forgot_password.sent_mail.warn")));
result.redirectTo(this).forgotPasswordForm();
} catch (EmailException e) {
validator.add(messageFactory.build("error", "forgot_password.send_mail.error"));
validator.onErrorRedirectTo(this).forgotPasswordForm();
}
}
Aggregations