<commit_before>﻿using App.Controller;
using App.Entity;
using App.UI;
using System;
using System.Windows.Forms;
using System.Linq;
using App.Factory;
using App.UI.PhaseThree;
using App.UI.PhaseTwo;
using ListenerMain = App.UI.PhaseTwo.ListenerMain;

namespace App
{
    /// <summary>
    /// 
    /// Login Form
    /// Author: <NAME>
    /// 
    /// </summary>
    public partial class Login : Form
    {
        private LoginController loginController;
        private Form parentForm;

        public Login(Form parentForm)
        {
            InitializeComponent();

            loginController = ApplicationFactory.getLoginController();
            this.parentForm = parentForm;
        }

        private void LoginButton_Click(object sender, EventArgs e)
        {
            string username = UserNameTextBox.Text;
            string password = <PASSWORD>.Text;

            User loggedUser = loginController.GetUser(username, password);
            if (loggedUser == null)
            {
                MessageBox.Show("The credentials are not valid");
            }
            else
            {
                if (loginController.IsConferenceActive() == true)
                {
                    string activePhaseName = loginController.ActiveConference().ActivePhase.Name;
                    Form toBeShown = null;
                    switch (activePhaseName)
                    {
                        case "PRELIMINARY":
                            if (loginController.GetUserRoles(loggedUser).Select(role => role.Slug).Contains("chair") ||
                                loginController.GetUserRoles(loggedUser).Select(role => role.Slug).Contains("reviewer"))
                            {
                                toBeShown = new PreliminaryPhase(this, loggedUser);
                            }
                            else
                            {
                                //User is a non-chair member and is restricted to access the website
                                MessageBox.Show("The conference is yet in preliminary phase!\nPlease wait until the set up is complete!");
                                return;
                            }
                            break;
                        case "PHASEONE":
                            toBeShown = new UserAccount(this, loggedUser);
                            break;
                        case "PHASETWO":
                            if (loginController.GetUserRoles(loggedUser).Select(role => role.Slug).Contains("chair"))
                            {
                                toBeShown = new ChairMain(this, loggedUser);
                            }
                            else if (loginController.GetUserRoles(loggedUser).Select(role => role.Slug).Contains("reviewer"))
                            {
                                toBeShown = new PCMemberMain(this, loggedUser);
                            }
                            else if (loginController.GetUserRoles(loggedUser).Select(role => role.Slug).Contains("author")
                                || loginController.GetUserRoles(loggedUser).Select(role => role.Slug).Contains("speaker"))
                            {
                                toBeShown = new AuthorMain(this, loggedUser);
                            }
                            else if (loginController.GetUserRoles(loggedUser).Select(role => role.Slug).Contains("listner"))
                            {
                                toBeShown = new ListenerMain(this, loggedUser);
                            }
                            break;
                        case "PHASETHREE":
                            if (loginController.GetUserRoles(loggedUser).Select(role => role.Slug).Contains("listner"))
                            {
                                toBeShown = new UI.PhaseThree.ListenerMain(this, loggedUser);
                            }
                            else if (loginController.GetUserRoles(loggedUser).Select(role => role.Slug).Contains("chair"))
                            {
                                toBeShown = new RoomsDistribution(this);
                            }
                            break;
                    }

                    toBeShown.Location = new System.Drawing.Point(Location.X, Location.Y);
                    toBeShown.Show();
                    Hide();
                }
                else
                {
                    if (loginController.GetUserRoles(loggedUser).Select(role => role.Slug).ToArray().Contains("chair"))
                    {
                        //User is a chair and is shown the preliminary phase
                        PreliminaryPhase preliminaryPhase = new PreliminaryPhase(this, loggedUser);
                        preliminaryPhase.Location = new System.Drawing.Point(Location.X, Location.Y);
                        preliminaryPhase.Show();
                        Hide();
                    }
                    else
                    {
                        //User is a non-chair member and is restricted to access the website
                        MessageBox.Show("There is no active conference for the moment!");
                    }
                }
            }
        }

        private void buttonBack_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void Login_Load(object sender, EventArgs e)
        {
            AcceptButton = LoginButton;
        }
<commit_msg>phase three login - support for all roles<commit_after>﻿using App.Controller;
using App.Entity;
using App.UI;
using System;
using System.Windows.Forms;
using System.Linq;
using App.Factory;
using App.UI.PhaseThree;
using App.UI.PhaseTwo;
using ListenerMain = App.UI.PhaseTwo.ListenerMain;

namespace App
{
    /// <summary>
    /// 
    /// Login Form
    /// Author: <NAME>
    /// 
    /// </summary>
    public partial class Login : Form
    {
        private LoginController loginController;
        private Form parentForm;

        public Login(Form parentForm)
        {
            InitializeComponent();

            loginController = ApplicationFactory.getLoginController();
            this.parentForm = parentForm;
        }

        private void LoginButton_Click(object sender, EventArgs e)
        {
            string username = UserNameTextBox.Text;
            string password = PasswordTextBox.Text;

            User loggedUser = loginController.GetUser(username, password);
            if (loggedUser == null)
            {
                MessageBox.Show("The credentials are not valid");
            }
            else
            {
                if (loginController.IsConferenceActive() == true)
                {
                    string activePhaseName = loginController.ActiveConference().ActivePhase.Name;
                    Form toBeShown = null;
                    switch (activePhaseName)
                    {
                        case "PRELIMINARY":
                            if (loginController.GetUserRoles(loggedUser).Select(role => role.Slug).Contains("chair") ||
                                loginController.GetUserRoles(loggedUser).Select(role => role.Slug).Contains("reviewer"))
                            {
                                toBeShown = new PreliminaryPhase(this, loggedUser);
                            }
                            else
                            {
                                //User is a non-chair member and is restricted to access the website
                                MessageBox.Show("The conference is yet in preliminary phase!\nPlease wait until the set up is complete!");
                                return;
                            }
                            break;
                        case "PHASEONE":
                            toBeShown = new UserAccount(this, loggedUser);
                            break;
                        case "PHASETWO":
                            if (loginController.GetUserRoles(loggedUser).Select(role => role.Slug).Contains("chair"))
                            {
                                toBeShown = new ChairMain(this, loggedUser);
                            }
                            else if (loginController.GetUserRoles(loggedUser).Select(role => role.Slug).Contains("reviewer"))
                            {
                                toBeShown = new PCMemberMain(this, loggedUser);
                            }
                            else if (loginController.GetUserRoles(loggedUser).Select(role => role.Slug).Contains("author")
                                || loginController.GetUserRoles(loggedUser).Select(role => role.Slug).Contains("speaker"))
                            {
                                toBeShown = new AuthorMain(this, loggedUser);
                            }
                            else if (loginController.GetUserRoles(loggedUser).Select(role => role.Slug).Contains("listner"))
                            {
                                toBeShown = new ListenerMain(this, loggedUser);
                            }
                            break;
                        case "PHASETHREE":
                            if (loginController.GetUserRoles(loggedUser).Select(role => role.Slug).Contains("listner"))
                            {
                                toBeShown = new UI.PhaseThree.ListenerMain(this, loggedUser);
                            }
                            else if (loginController.GetUserRoles(loggedUser).Select(role => role.Slug).Contains("chair"))
                            {
                                toBeShown = new RoomsDistribution(this);
                            }
                            else
                            {
                                MessageBox.Show("Conference is current commencing", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                            break;
                    }
                    if (toBeShown != null)
                    {
                        toBeShown.Location = new System.Drawing.Point(Location.X, Location.Y);
                        toBeShown.Show();
                        Hide();
                    }
                }
                else
                {
                    if (loginController.GetUserRoles(loggedUser).Select(role => role.Slug).ToArray().Contains("chair"))
                    {
                        //User is a chair and is shown the preliminary phase
                        PreliminaryPhase preliminaryPhase = new PreliminaryPhase(this, loggedUser);
                        preliminaryPhase.Location = new System.Drawing.Point(Location.X, Location.Y);
                        preliminaryPhase.Show();
                        Hide();
                    }
                    else
                    {
                        //User is a non-chair member and is restricted to access the website
                        MessageBox.Show("There is no active conference for the moment!");
                    }
                }
            }
        }

        private void buttonBack_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void Login_Load(object sender, EventArgs e)
        {
            AcceptButton = LoginButton;
        }

{'fraction_non_alphanumeric': 0.08050995459308417, 'fraction_numerical': 0.0, 'mean_word_length': 1.1033976124885216, 'pattern_counts': {'":': 8, '<': 10, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2837453', 'n_tokens_mistral': 2569, 'n_tokens_neox': 2425, 'n_words': 519}