Search in sources :

Example 26 with User

use of models.User in project play-cookbook by spinscale.

the class CsvTest method saveEntityWithLinkToAnother.

@Test
public void saveEntityWithLinkToAnother() throws Exception {
    User u = new User();
    u.name = "alex";
    u.currentCar = c;
    u.save();
    String data = FileUtils.readFileToString(new File("/tmp/User.csv"));
    String expected = "\"1\"\t\"alex\"\t\"#Car#1\"\n";
    assertEquals(expected, data);
}
Also used : User(models.User) File(java.io.File) UnitTest(play.test.UnitTest) Test(org.junit.Test)

Example 27 with User

use of models.User in project play-cookbook by spinscale.

the class DigestRequest method isAuthorized.

public boolean isAuthorized() {
    User user = User.find("byName", params.get("username")).first();
    if (user == null) {
        throw new UnauthorizedDigest(params.get("realm"));
    }
    String digest = createDigest(user.apiPassword);
    return digest.equals(params.get("response"));
}
Also used : User(models.User)

Example 28 with User

use of models.User in project play-cookbook by spinscale.

the class AddUserOnStartJob method doJob.

public void doJob() {
    if (User.count("byName", "alex") == 0) {
        User user = new User();
        user.name = "alex";
        user.password = Crypto.passwordHash("foo");
        user.apiPassword = "test";
        user.save();
    }
}
Also used : User(models.User)

Example 29 with User

use of models.User in project play-cookbook by spinscale.

the class Application method quote.

public static void quote() {
    String username = Cache.get("ticket:" + request.headers.get("x-authorization").value(), String.class);
    User user = User.find("byName", username).first();
    String quote = user.quote;
    render(quote);
}
Also used : User(models.User)

Example 30 with User

use of models.User in project play-cookbook by spinscale.

the class Application method login.

public static void login(String login, String password) {
    User user = User.find("byLoginAndPassword", login, password).first();
    notFoundIfNull(user);
    session.put("login", user.login);
    showTweets(user.login);
}
Also used : User(models.User)

Aggregations

User (models.User)30 CurrentUser (actions.CurrentUser)7 CurrentUser.currentUser (actions.CurrentUser.currentUser)7 Test (org.junit.Test)7 Result (play.mvc.Result)7 Module (models.Module)6 UnitTest (play.test.UnitTest)6 RoleHolderPresent (be.objectify.deadbolt.actions.RoleHolderPresent)5 Vote (models.Vote)4 EntityManager (javax.persistence.EntityManager)3 Rate (models.Rate)3 Registration (models.Registration)3 SolrQuery (org.apache.solr.client.solrj.SolrQuery)3 Transactional (com.google.inject.persist.Transactional)2 VoteResponseForm (forms.modules.VoteResponseForm)2 Query (javax.persistence.Query)2 Article (models.Article)2 ModuleVersion (models.ModuleVersion)2 PlayVersion (models.PlayVersion)2 Tweet (models.Tweet)2