示例#1
0
        public async Task <bool> PerformLogin(string username, string password)
        {
            // Empty ung input so error
            if (username == "" || password == "")
            {
                view.DisplayLoginError(true);
                return(false);
            }

            // TODO Kung sakali, strip ung special

            // Get Account Session details
            Account loggedAccount = await accService.GetAccountAsSession(username);

            if (loggedAccount == null)
            {
                view.DisplayLoginError(true);
                return(false);
            }

            // username exists, check na natin kung tama ung password
            view.DisplayLoginError(false);

            // verify natin ung password na input at ni account
            Password userPassword = await passService.GetPasswordByUsername(username);

            bool validPass = await hashService.VerifyPasswordHashAsync(password, userPassword);

            // pag di valid, show tayo ng error
            if (!validPass)
            {
                view.DisplayLoginError(true);
                return(false);
            }

            // create ung session sa nag log in na account
            loginSession = SessionFactory.CreateSession <AccountSession>(SessionKeys.LoginKey);
            loginSession.AddAccountSession(loggedAccount);

            // invalid ung account type
            if (loggedAccount.AccTypeId == null)
            {
                return(false);
            }

            //TODO TANGAL MO KO
            Logger.Debug(loggedAccount);

            // user exists and valid na ung password, so login na given ung account type for activity
            view.UserLoginSuccess((AccountType)loggedAccount.AccTypeId);
            return(true);
        }
示例#2
0
        public async void PerformLogin(string username, string password)
        {
            // check if username exists
            // f = show invalid
            // t => get salt and hash of username
            // use encryption to check
            // f = show invalid

            // Empty
            if (username == "" || password == "")
            {
                view.DisplayLoginError(true);
                return;
            }

            // TODO Kung sakali, strip ung special
            // dapat malaman kung anong klaseng account
            AccountType?type = await accService.GetAccountType(username);

            if (type == null)
            {
                view.DisplayLoginError(true);
                return;
            }

            // username exists, check na natin kung tama ung password
            view.DisplayLoginError(false);

            Password userPassword = await passService.GetPasswordByUsername(username);

            bool validPass = hashService.VerifyPasswordHash(password, userPassword);

            if (!validPass)
            {
                view.DisplayLoginError(true);
                return;
            }

            // kailangan malaman kung anong type ng user sya pala
            // user exists and valid na ung password na binigay so login na

            // TODO Create dito ung Login Session
            view.UserLoginSuccess();

            //loginSession = SessionFactory.CreateSession <LoginSession> (SessionKeys.LoginKey);
            // loginSession.Login(username, type);
        }