Search in sources :

Example 1 with UserServices

use of services.UserServices in project modules.playframework.org by playframework.

the class Global method onStart.

@Override
public void onStart(Application application) {
    // Add code or TODOs here for startup behaviour
    // todo - add a scheduled job that selects a given number - maybe 2? - of modules and makes them the featured modules of the day
    // the previous day's featured modules are removed, if they are not sticky
    // the description of the featured module will be taken from the module summary, but may be overwritten from the admin console to something specific
    // featured modules created in this way are not sticky.
    // featured modules can be made sticky to have them stick around for more than 24 hours via admin console - featured modules can also be created from there
    // I'll add this to the wiki later
    // this space for rent
    // TODO remove this!  It's a development convenience
    Logger.info("Adding admin user...");
    if (UserRole.findByRoleName(RoleDefinitions.ADMIN) == null) {
        UserRole role = new UserRole();
        role.roleName = RoleDefinitions.ADMIN;
        role.description = "MPO administrator";
        role.save();
    }
    if (User.findByUserName("admin") == null) {
        new UserServices().createUser("admin", "MPO Admin", "password", Arrays.asList(UserRole.findByRoleName(RoleDefinitions.ADMIN)));
    }
    loadInitialData();
    scheduleJobs();
}
Also used : UserServices(services.UserServices)

Example 2 with UserServices

use of services.UserServices in project modules.playframework.org by playframework.

the class Application method createAccount.

public static Result createAccount() {
    Form<Register> registerForm = form(Register.class).bindFromRequest();
    Result result;
    if (registerForm.hasErrors()) {
        result = badRequest(register.render(registerForm));
    } else {
        Register register = registerForm.get();
        new UserServices().createUser(register.userName, register.displayName, register.password);
        session("userName", register.userName);
        result = redirect(routes.Application.index());
    }
    return result;
}
Also used : UserServices(services.UserServices) Register(forms.login.Register) Result(play.mvc.Result)

Aggregations

UserServices (services.UserServices)2 Register (forms.login.Register)1 Result (play.mvc.Result)1