<commit_before>package com.saviour.poweryoga.controller;

import com.saviour.poweryoga.model.Role;
import com.saviour.poweryoga.model.Users;
import com.saviour.poweryoga.serviceI.IUserService;
import com.saviour.poweryoga.util.PasswordService;
import java.io.Serializable;
import javax.enterprise.context.SessionScoped;
import javax.faces.application.ConfigurableNavigationHandler;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.faces.event.ComponentSystemEvent;
import javax.inject.Named;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;

/**
 *
 * @author TalakB
 * @version 0.0.1
 */
@Named
@SessionScoped
public class UserController implements Serializable {

    @Autowired
    private IUserService userService;

    //for success and error message notifications 
    @Autowired
    private NotificationController notoficationController;
//    

    private Users user;
    //= new Users();
    private Role userRole;

    //to keep user related data on the session 
    private HttpSession activeSession;

    private boolean isAdmin;
    private boolean isFaculty;
    private boolean isCustomer;
    private boolean isLoggedin;

    private static String redirect = "";

    public static String getRedirect() {
        return redirect;
    }

    public static void setRedirect(String redirect) {
        UserController.redirect = redirect;
    }

    public UserController() {
        user = new Users();
        userRole = new Role();
    }

    public Users getUser() {
        return user;
    }

    public void setUser(Users user) {
        this.user = user;
    }

    public HttpSession getActiveSession() {
        return activeSession;
    }

    public void setActiveSession(HttpSession activeSession) {
        this.activeSession = activeSession;
    }

    public boolean isIsAdmin() {
        return isAdmin;
    }

    public void setIsAdmin(boolean isAdmin) {
        this.isAdmin = isAdmin;
    }

    public boolean isIsFaculty() {
        return isFaculty;
    }

    public void setIsFaculty(boolean isFaculty) {
        this.isFaculty = isFaculty;
    }

    public boolean isIsCustomer() {
        return isCustomer;
    }

    public void setIsCustomer(boolean isCustomer) {
        this.isCustomer = isCustomer;
    }

    public boolean isIsLoggedin() {
        return isLoggedin;
    }

    public void setIsLoggedin(boolean isLoggedin) {
        this.isLoggedin = isLoggedin;
    }

    /**
     * Authenticate user and redirect to the respective home page based on role.
     *
     * @return
     * @throws Exception
     */
    public String loginUser() throws Exception {

        //encrypt password to check it against the DB. 
        String encPass = PasswordService.encrypt(user.getPassword());
        user.setPassword(encPass);
        String retURL = "";
        try {
            user = userService.authenticateUser(user);
            //check if the user is registered and authenticated 
            if (user != null) {
                //set the authenticated user info. on the session  
                setUserSessionData(user);

                //check user code 
                int userRoleCode = user.getRole().getUserCode();
                //admin
                if (userRoleCode == Role.ROLE_ADMIN_CODE) {
                    isAdmin = true;
                    retURL = "/views/admin/adminHome.xhtml?faces-redirect=true";
                } //faculty user 
                else if (userRoleCode == Role.ROLE_FACULTY_CODE) {
                    // activeSession.setAttribute("loggedUser", user);
//                userLogged = true;
//                isAdminUser = true;
                    isFaculty = true;
                    retURL = "/views/faculty/facultyHome.xhtml?faces-redirect=true";

                } //vedor user
                else if (userRoleCode == Role.ROLE_CUSTOMER_CODE) {
                    // activeSession.setAttribute("loggedUser", user);
//                userLogged = true;
//                isAdminUser = true;
                    isCustomer = true;
                    retURL = "/views/index.xhtml?faces-redirect=true";
                }

            } else {
                FacesContext.getCurrentInstance()
                        .addMessage("logInForm:unamePassErr", new FacesMessage("Please check username and/or password.", "Please check username and/or password."));

                return null;
            }
            if (redirect != null && redirect.length() > 0) {
                return redirect;
            } else {
                return retURL;
            }

        } catch (Exception ex) {
            ex.printStackTrace();
            //    notoficationController.setErrorMsg("Login failed. Please cehck username/password.");
        }<commit_msg>Login Null return null solution<commit_after>package com.saviour.poweryoga.controller;

import com.saviour.poweryoga.model.Role;
import com.saviour.poweryoga.model.Users;
import com.saviour.poweryoga.serviceI.IUserService;
import com.saviour.poweryoga.util.PasswordService;
import java.io.Serializable;
import javax.enterprise.context.SessionScoped;
import javax.faces.application.ConfigurableNavigationHandler;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.faces.event.ComponentSystemEvent;
import javax.inject.Named;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;

/**
 *
 * @author TalakB
 * @version 0.0.1
 */
@Named
@SessionScoped
public class UserController implements Serializable {

    @Autowired
    private IUserService userService;

    //for success and error message notifications 
    @Autowired
    private NotificationController notoficationController;
//    

    private Users user;
    //= new Users();
    private Role userRole;

    //to keep user related data on the session 
    private HttpSession activeSession;

    private boolean isAdmin;
    private boolean isFaculty;
    private boolean isCustomer;
    private boolean isLoggedin;

    private static String redirect = "";

    public static String getRedirect() {
        return redirect;
    }

    public static void setRedirect(String redirect) {
        UserController.redirect = redirect;
    }

    public UserController() {
        user = new Users();
        userRole = new Role();
    }

    public Users getUser() {
        return user;
    }

    public void setUser(Users user) {
        this.user = user;
    }

    public HttpSession getActiveSession() {
        return activeSession;
    }

    public void setActiveSession(HttpSession activeSession) {
        this.activeSession = activeSession;
    }

    public boolean isIsAdmin() {
        return isAdmin;
    }

    public void setIsAdmin(boolean isAdmin) {
        this.isAdmin = isAdmin;
    }

    public boolean isIsFaculty() {
        return isFaculty;
    }

    public void setIsFaculty(boolean isFaculty) {
        this.isFaculty = isFaculty;
    }

    public boolean isIsCustomer() {
        return isCustomer;
    }

    public void setIsCustomer(boolean isCustomer) {
        this.isCustomer = isCustomer;
    }

    public boolean isIsLoggedin() {
        return isLoggedin;
    }

    public void setIsLoggedin(boolean isLoggedin) {
        this.isLoggedin = isLoggedin;
    }

    /**
     * Authenticate user and redirect to the respective home page based on role.
     *
     * @return
     * @throws Exception
     */
    public String loginUser() throws Exception {

        //encrypt password to check it against the DB. 
        String encPass = PasswordService.encrypt(user.getPassword());
        user.setPassword(encPass);
        String retURL = "";
        try {
            user = userService.authenticateUser(user);
            //check if the user is registered and authenticated 
            if (user != null) {
                //set the authenticated user info. on the session  
                setUserSessionData(user);

                //check user code 
                int userRoleCode = user.getRole().getUserCode();
                //admin
                if (userRoleCode == Role.ROLE_ADMIN_CODE) {
                    isAdmin = true;
                    retURL = "/views/admin/adminHome.xhtml?faces-redirect=true";
                } //faculty user 
                else if (userRoleCode == Role.ROLE_FACULTY_CODE) {
                    // activeSession.setAttribute("loggedUser", user);
//                userLogged = true;
//                isAdminUser = true;
                    isFaculty = true;
                    retURL = "/views/faculty/facultyHome.xhtml?faces-redirect=true";

                } //vedor user
                else if (userRoleCode == Role.ROLE_CUSTOMER_CODE) {
                    // activeSession.setAttribute("loggedUser", user);
//                userLogged = true;
//                isAdminUser = true;
                    isCustomer = true;
                    retURL = "/views/index.xhtml?faces-redirect=true";
                }

            } else {
                FacesContext.getCurrentInstance()
                        .addMessage("logInForm:unamePassErr", new FacesMessage("Please check username and/or password.", "Please check username and/or password."));
                user=new Users();
                return null;
            }
            if (redirect != null && redirect.length() > 0) {
                return redirect;
            } else {
                return retURL;
            }

        } catch (Exception ex) {
            ex.printStackTrace();
            //    notoficationController.setErrorMsg("Login failed. Please cehck username/password.");
        }
{'fraction_non_alphanumeric': 0.08736572890025575, 'fraction_numerical': 0.0008184143222506394, 'mean_word_length': 2.0341402855369335, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1375899', 'n_tokens_mistral': 2642, 'n_tokens_neox': 2512, 'n_words': 632}