Package org.b3log.latke.user

Examples of org.b3log.latke.user.GeneralUser


     * returns {@code false} otherwise
     */
    public boolean isLoggedIn(final HttpServletRequest request, final HttpServletResponse response) {
        userMgmtService.tryLogInWithCookie(request, response);

        final GeneralUser currentUser = userService.getCurrentUser(request);

        return null != currentUser;
    }
View Full Code Here


     *
     * @param request the specified request
     * @return the current user, {@code null} if not found
     */
    public JSONObject getCurrentUser(final HttpServletRequest request) {
        final GeneralUser currentUser = userService.getCurrentUser(request);

        if (null == currentUser) {
            return null;
        }

        final String email = currentUser.getEmail();

        try {
            return userRepository.getByEmail(email);
        } catch (final RepositoryException e) {
            LOGGER.log(Level.ERROR, "Gets current user by request failed, returns null", e);
View Full Code Here

        final HttpServletRequest httpServletRequest = (HttpServletRequest) request;

        try {
            LoginProcessor.tryLogInWithCookie(httpServletRequest, httpServletResponse);

            final GeneralUser currentUser = userService.getCurrentUser(httpServletRequest);
            if (null == currentUser) {
                LOGGER.warning("The request has been forbidden");
                httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN);

                return;
            }

            final String currentUserEmail = currentUser.getEmail();
            LOGGER.log(Level.FINER, "Current user email[{0}]", currentUserEmail);
            if (users.isSoloUser(currentUserEmail)) {
                chain.doFilter(request, response);

                return;
View Full Code Here

     * returns {@code false} otherwise
     */
    public boolean isLoggedIn(final HttpServletRequest request, final HttpServletResponse response) {
        LoginProcessor.tryLogInWithCookie(request, response);

        final GeneralUser currentUser = userService.getCurrentUser(request);
        if (null == currentUser) {
            return false;
        }

        return isSoloUser(currentUser.getEmail()) || userService.isUserAdmin(request);
    }
View Full Code Here

     *
     * @param request the specified request
     * @return the current user, {@code null} if not found
     */
    public JSONObject getCurrentUser(final HttpServletRequest request) {
        final GeneralUser currentUser = userService.getCurrentUser(request);
        if (null == currentUser) {
            return null;
        }

        final String email = currentUser.getEmail();

        try {
            return userRepository.getByEmail(email);
        } catch (final RepositoryException e) {
            LOGGER.log(Level.SEVERE, "Gets current user by request failed, returns null", e);
View Full Code Here

                           final HttpServletResponse response)
            throws Exception {
        LOGGER.info("Initializing admin....");
        final JSONObject admin = new JSONObject();

        final GeneralUser user = userService.getCurrentUser();
        final String name = user.getNickname();
        admin.put(User.USER_NAME, name);
        final String email = user.getEmail();
        admin.put(User.USER_EMAIL, email);
        admin.put(User.USER_ROLE, Role.ADMIN_ROLE);

        addUser(admin, request, response);
View Full Code Here

                    //    Because of there is no any user in datastore before init Solo
                    //    although the administrator has been logged in for init
                    // 2. The collaborate administrator
                    ret.put(Common.IS_LOGGED_IN, true);
                    ret.put(Common.IS_ADMIN, true);
                    final GeneralUser admin = userService.getCurrentUser();
                    ret.put(User.USER_NAME, admin.getNickname());
                }

                ret.put(Common.LOGIN_URL,
                        userService.createLoginURL("/admin-index.do"));
View Full Code Here

                                                         ServletException {
        final HttpServletResponse httpServletResponse =
                (HttpServletResponse) response;

        try {
            final GeneralUser currentUser = userService.getCurrentUser();
            if (null == currentUser) {
                LOGGER.warning("The request has been forbidden");
                httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN);

                return;
            }

            final String currentUserEmail = currentUser.getEmail();
            LOGGER.log(Level.FINER, "Current user email[{0}]", currentUserEmail);
            if (users.isSoloUser(currentUserEmail)
                || users.isCollaborateAdmin()) {
                chain.doFilter(request, response);
View Full Code Here

        final boolean isUserAdmin = userService.isUserAdmin();
        if (!isUserAdmin) {
            return false;
        }

        final GeneralUser currentUser = userService.getCurrentUser();
        return !isSoloUser(currentUser.getEmail());
    }
View Full Code Here

     *
     * @return {@code true} if the current request is made by logged in user,
     * returns {@code false} otherwise
     */
    public boolean isLoggedIn() {
        final GeneralUser currentUser = userService.getCurrentUser();
        if (null == currentUser) {
            return false;
        }

        return isSoloUser(currentUser.getEmail()) || userService.isUserAdmin();
    }
View Full Code Here

TOP

Related Classes of org.b3log.latke.user.GeneralUser

Copyright © 2018 www.massapicom. 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.