Search in sources :

Example 1 with User

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);
}
Also used : User(org.mamute.model.User) XStream(com.thoughtworks.xstream.XStream)

Example 2 with User

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);
}
Also used : User(org.mamute.model.User) MergeLoginMethod(org.mamute.auth.MergeLoginMethod) LoginMethod(org.mamute.model.LoginMethod)

Example 3 with 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;
}
Also used : User(org.mamute.model.User) SignupInfo(org.mamute.auth.SignupInfo)

Example 4 with User

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());
}
Also used : User(org.mamute.model.User) LoggedUser(org.mamute.model.LoggedUser) News(org.mamute.model.News) NewsInformation(org.mamute.model.NewsInformation) CustomBrutauthRules(br.com.caelum.brutauth.auth.annotations.CustomBrutauthRules) Post(br.com.caelum.vraptor.Post)

Example 5 with User

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();
    }
}
Also used : User(org.mamute.model.User) Email(org.apache.commons.mail.Email) EmailException(org.apache.commons.mail.EmailException) Post(br.com.caelum.vraptor.Post)

Aggregations

User (org.mamute.model.User)97 Test (org.junit.Test)56 Question (org.mamute.model.Question)28 LoggedUser (org.mamute.model.LoggedUser)25 VRaptorTestResult (br.com.caelum.vraptor.test.VRaptorTestResult)9 UserFlow (br.com.caelum.vraptor.test.requestflow.UserFlow)9 Answer (org.mamute.model.Answer)9 LoginMethod (org.mamute.model.LoginMethod)9 Post (br.com.caelum.vraptor.Post)7 Before (org.junit.Before)7 Tag (org.mamute.model.Tag)7 QuestionInformation (org.mamute.model.QuestionInformation)6 Email (org.apache.commons.mail.Email)5 UserPersonalInfo (org.mamute.dto.UserPersonalInfo)5 ReputationEvent (org.mamute.model.ReputationEvent)5 ArrayList (java.util.ArrayList)4 Watcher (org.mamute.model.watch.Watcher)4 DateTime (org.joda.time.DateTime)3 Elements (org.jsoup.select.Elements)3 DaoManager (org.mamute.integration.util.DaoManager)3