<commit_before>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.mycompany.rboss.controller;


import com.mycompany.rboss.domain.Category;
import com.mycompany.rboss.domain.CreditCard;
import com.mycompany.rboss.domain.Product;
import com.mycompany.rboss.domain.User;
import com.mycompany.rboss.service.CategoryService;
import com.mycompany.rboss.service.CreditCardService;
import com.mycompany.rboss.service.ProductService;
import com.mycompany.rboss.service.UserService;
import static com.mycompany.rboss.service.UserService.SERVER_URI;
import java.security.Principal;
import java.util.ArrayList;
import java.util.UUID;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

/**
 *
 * @author bin
 */
@Controller
public class UserController {
    
    @Autowired
    private UserService userService;
    
    @Autowired
    private CreditCardService creditcardservice;
    
    @Autowired
    private JavaMailSender mailSender;
    @Autowired
    private PasswordEncoder encoder;
    @Autowired
    private CategoryService categoryService;
    @Autowired
    private ProductService productService;
    
    @RequestMapping("/")
    public String index(Model model) {
        List<Category> allCategories = categoryService.getAll();
        model.addAttribute("categories", allCategories);
        
        List<Product> newProducts = productService.getAllNew();
        model.addAttribute("newProducts", newProducts);
        
        List<Product> featuredProducts = productService.getAllFeatured();
        model.addAttribute("featuredProducts", featuredProducts);
        return "user/index";
    }
    
    @RequestMapping(value="/adminlogin", method = RequestMethod.GET)
    public String adminlogin(){
        return "admin/login";
    }
    
    @RequestMapping("/customLoginFailPage")
    public String customLoginFailPage(Model model) {
        model.addAttribute("msg", "Invalid Username or Password, please try again");
        return "user/login";
    }
    
    
    
    
     @RequestMapping("/faculty")
    public String facultyHome() {
        return "facultyHome";
    }
     @RequestMapping("/admin")
    public String adminHome() {
        return "adminHome";
    }
    
    @RequestMapping("/home")
    public String home() {
        return "home";
    }
    @RequestMapping("/default")
    public String gohome() {
        return "user/index";
    }

    
     @RequestMapping("/login")
    public String login() {
        return "user/login";<commit_msg>minor changes<commit_after>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.mycompany.rboss.controller;


import com.mycompany.rboss.domain.Category;
import com.mycompany.rboss.domain.CreditCard;
import com.mycompany.rboss.domain.Product;
import com.mycompany.rboss.domain.User;
import com.mycompany.rboss.service.CategoryService;
import com.mycompany.rboss.service.CreditCardService;
import com.mycompany.rboss.service.ProductService;
import com.mycompany.rboss.service.UserService;
import static com.mycompany.rboss.service.UserService.SERVER_URI;
import java.security.Principal;
import java.util.ArrayList;
import java.util.UUID;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

/**
 *
 * @author bin
 */
@Controller
public class UserController {
    
    @Autowired
    private UserService userService;
    
    @Autowired
    private CreditCardService creditcardservice;
    
    @Autowired
    private JavaMailSender mailSender;
    @Autowired
    private PasswordEncoder encoder;
    @Autowired
    private CategoryService categoryService;
    @Autowired
    private ProductService productService;
    
    @RequestMapping("/")
    public String index(Model model) {
        List<Category> allCategories = categoryService.getAll();
        model.addAttribute("categories", allCategories);
        
        List<Product> newProducts = productService.getAllNew();
        model.addAttribute("newProducts", newProducts);
        
        List<Product> featuredProducts = productService.getAllFeatured();
        model.addAttribute("featuredProducts", featuredProducts);
        return "user/index";
    }
    
    @RequestMapping(value="/adminlogin", method = RequestMethod.GET)
    public String adminlogin(){
        return "admin/login";
    }
    
    @RequestMapping("/customLoginFailPage")
    public String customLoginFailPage(Model model) {
        model.addAttribute("msg", "Invalid Username or Password, please try again");
        return "user/login";
    }
    
    
    
    
     @RequestMapping("/faculty")
    public String facultyHome() {
        return "facultyHome";
    }
     @RequestMapping("/admin")
    public String adminHome() {
        return "adminHome";
    }
    
    @RequestMapping("/home")
    public String home() {
        return "home";
    }
    @RequestMapping("/default")
    public String gohome(Model model) {
        List<Category> allCategories = categoryService.getAll();
        model.addAttribute("categories", allCategories);
        
        List<Product> newProducts = productService.getAllNew();
        model.addAttribute("newProducts", newProducts);
        
        List<Product> featuredProducts = productService.getAllFeatured();
        model.addAttribute("featuredProducts", featuredProducts);
        return "user/index";
    }

    
     @RequestMapping("/login")
    public String login() {
        return "user/login";
{'fraction_non_alphanumeric': 0.09914668833807395, 'fraction_numerical': 0.0, 'mean_word_length': 3.8547008547008548, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, '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': '1462808', 'n_tokens_mistral': 1949, 'n_tokens_neox': 1939, 'n_words': 402}