Package controllers

Source Code of controllers.Application

package controllers;

import models.User;

import org.bson.types.ObjectId;

import play.Logger;
import play.mvc.Before;
import play.mvc.Controller;
import utils.Secure;

public class Application extends Controller {

    public static void index() {
        render();
    }

    @Before
    public static void login() {
        Secure secure = getActionAnnotation(Secure.class);
        Logger.info("login checking , user id = " + session.get("USER_ID"));
        if (secure != null && secure.login()) {
            if (session.get("USER_ID") == null) {
                Logger.info("user id is null , need login");
                Users.needLogin();
            }
            String userId = session.get("USER_ID").toString();
            User user = User.filter("_id", new ObjectId(userId)).first();
            if (user == null) {
                Logger.info("user is null , need login");
                Users.needLogin();
            }
        }
    }
}
TOP

Related Classes of controllers.Application

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.