<commit_before>package at.ac.tuwien.inso.controller;

import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import at.ac.tuwien.inso.entity.Role;
import at.ac.tuwien.inso.entity.UserAccount;

@Controller
@RequestMapping("/")
public class RootController {

    @GetMapping
    public String getLogin(Authentication auth) {
        UserAccount userAccount = (UserAccount) auth.getPrincipal();

        if (userAccount.hasRole(Role.ADMIN)) {
            return "redirect:/admin/studyplans";
        } else if (userAccount.hasRole(Role.LECTURER)) {
            return "redirect:/lecturer/courses";
        } else {
            return "redirect:/student/courses";
        }
    }
}<commit_msg>Forward previously set flash attributes<commit_after>package at.ac.tuwien.inso.controller;

import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import java.util.Map;

import at.ac.tuwien.inso.entity.Role;
import at.ac.tuwien.inso.entity.UserAccount;

@Controller
@RequestMapping("/")
public class RootController {

    @GetMapping
    public String getLogin(Authentication auth, Model model, RedirectAttributes redirectAttributes) {

        // Keep flash attributes in the next view
        Map<String, Object> attributesMap = model.asMap();
        for (String modelKey : attributesMap.keySet()) {
            redirectAttributes.addFlashAttribute(modelKey, attributesMap.get(modelKey));
        }

        UserAccount userAccount = (UserAccount) auth.getPrincipal();

        if (userAccount.hasRole(Role.ADMIN)) {
            return "redirect:/admin/studyplans";
        } else if (userAccount.hasRole(Role.LECTURER)) {
            return "redirect:/lecturer/courses";
        } else {
            return "redirect:/student/courses";
        }
    }
}
{'fraction_non_alphanumeric': 0.10798548094373865, 'fraction_numerical': 0.0, 'mean_word_length': 3.6617336152219875, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '4891865', 'n_tokens_mistral': 620, 'n_tokens_neox': 601, 'n_words': 111}