public bool ValidateLogin(LogInInfo loginInfo)
        {
            LoginInfoDTO loginInfoDTO = new LoginInfoDTO();

            loginInfoDTO.Username = loginInfo.Username;
            loginInfoDTO.Password = loginInfo.Password;

            try
            {
                patientInfoDTO = API.GetObject <PatientInfoDTO, LoginInfoDTO>("PatientLogin", loginInfoDTO);
            }
            catch (WebException e) when((e.Response as HttpWebResponse)?.StatusCode == HttpStatusCode.NotFound)
            {
                Console.WriteLine(e);
            }

            if (patientInfoDTO.CPR != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        public ActionResult Index(LogInInfo usr)
        {
            AuthService service = new AuthService();
            int         UserId  = service.login(usr.Username, usr.Password);

            if (UserId == 0)
            {
                return(RedirectToAction("index", "Login"));
            }

            else
            {
                int type = service.getType(UserId);
                Session["USERID"] = UserId;
                Session["TYPE"]   = type;

                if (type == 1)
                {
                    return(RedirectToAction("index", "Users"));
                }
                else if (type == 2)
                {
                    return(RedirectToAction("index", "Owner"));
                }
                else
                {
                }
            }
            return(View("login"));
        }
Exemplo n.º 3
0
        public ActionResult Signup(UserRegistration form)
        {
            if (form.Password != form.ConfirmPassword)
            {
                ViewBag.msg = "Password does not match";
                return(RedirectToAction("ownerSignup", "Login"));
            }

            LogInInfo log = new LogInInfo
            {
                Username  = form.Username,
                Password  = form.Password,
                Type      = 2,
                IsBlocked = 0
            };

            Owner usr = new Owner
            {
                Mobile = form.Mobile,
                Email  = form.Email
            };

            OwnerService service = new OwnerService();

            if (service.register(log, usr))
            {
                return(RedirectToAction("index", "Login"));
            }
            else
            {
                ViewBag.msg2 = "Username Already Exists";
                return(RedirectToAction("ownerSignup", "Login"));
            }
        }
Exemplo n.º 4
0
        public bool register(LogInInfo log, User aUser)
        {
            PsDbContex db = new PsDbContex();

            LogInInfo el = db.LogInfos.SingleOrDefault(r => r.Username == log.Username);

            if (el != null)
            {
                return(false);
            }

            LogInInfo newInfo = new LogInInfo
            {
                ID        = 10,
                Username  = log.Username,
                Password  = log.Password,
                Type      = 1,
                IsBlocked = 0
            };


            db.LogInfos.Add(newInfo);
            db.SaveChanges();

            string           _username = log.Username;
            List <LogInInfo> logs;

            try
            {
                var res = from info in db.LogInfos
                          where info.Username == _username
                          select info;
                logs = res.ToList();
            }
            catch (Exception ex)
            {
                return(false);
            }

            if (logs.Count != 1)
            {
                return(false);
            }

            User newUser = new User
            {
                ID           = 10,
                UserId       = logs[0].ID,
                Email        = aUser.Email,
                Mobile       = aUser.Mobile,
                CarModel     = aUser.CarModel,
                LicensNumber = aUser.LicensNumber
            };

            db.Users.Add(newUser);
            db.SaveChanges();

            return(true);
        }
        public async Task <UserSignInModel> GetSignInInfoAsync(LogInInfo logInCommand)
        {
            var user = await ReadRepository.GetSingleAsync(_userFiltersProvider.ActiveByEmail(logInCommand.Email), _userRelationsProvider.JoinRole);

            return(user != null && user.PasswordHash.Equals(logInCommand.PasswordHash, StringComparison.OrdinalIgnoreCase)
                ? Mapper.Map <UserSignInModel>(user)
                : null);
        }
Exemplo n.º 6
0
        public IActionResult LogIn(LogInInfo info)
        {
            string        returnpage = "";
            List <string> account    = new List <string>();

            using (StreamReader reader = new StreamReader("C:/Users/g.morleschi/source/repos/ScacchiOnline/ClientScacchi/DB.csv"))
            {
                string line = reader.ReadLine();
                while (line != null)
                {
                    account.Add(line);
                    line = reader.ReadLine();
                }
            }
            if (!Request.Cookies.ContainsKey("token"))
            {
                foreach (string userinfo in account)
                {
                    if (userinfo.ToLower().Contains(info.Name.ToLower()))
                    {
                        if (userinfo.ToLower().Contains(info.Password.ToLower()))
                        {
                            Response.Cookies.Delete("token");
                            returnpage = "Lobby";
                            SynchronousSocketClient.StartClient("Player ; User: "******" ; " + "Password: "******"token", userClient.Token, options);


                            break;
                        }
                        else
                        {
                            returnpage = "LogIn";
                            break;
                        }
                    }
                }
            }
            else
            {
                returnpage = "Lobby";
            }

            return(View(returnpage));
        }
Exemplo n.º 7
0
        public string getUsername(int id)
        {
            PsDbContex db = new PsDbContex();

            LogInInfo el = db.LogInfos.SingleOrDefault(r => r.ID == id);

            if (el == null)
            {
                return("undefined");
            }
            return(el.Username);
        }
Exemplo n.º 8
0
        public int getType(int id)
        {
            PsDbContex db = new PsDbContex();

            LogInInfo el = db.LogInfos.SingleOrDefault(r => r.ID == id);

            if (el == null)
            {
                return(-1);
            }
            return(el.Type);
        }
Exemplo n.º 9
0
    IEnumerator Submit()
    {
        List <IMultipartFormSection> formData = new List <IMultipartFormSection>();

        for (int i = 0; i < Mathf.Min(variableNames.Length, inputFields.Length); i++)
        {
            formData.Add(new MultipartFormDataSection(variableNames[i], inputFields[i].text));
        }

        UnityWebRequest www = UnityWebRequest.Post(URL, formData);

        yield return(www.SendWebRequest());

        if (www.isNetworkError || www.isHttpError)
        {
            Debug.Log(www.error);
        }
        else
        {
            string value = www.downloadHandler.text;
            if (isServerLogIn)
            {
                if (www.downloadHandler.text != "0")
                {
                    sessionID.Value = value;
                    Debug.Log(sessionID.Value);
                    feedbackText.text = "Logging in...";
                    SceneLoader.LoadNextScene();
                }
                else
                {
                    feedbackText.text = "Server does not exist or password is incorrect";
                }
            }
            else
            {
                if (www.downloadHandler.text == "Invalid email")
                {
                    feedbackText.text = "Invalid e-mail";
                }
                if (www.downloadHandler.text != "0")
                {
                    LogInInfo logInInfo = new LogInInfo();
                    logInInfo         = JsonUtility.FromJson <LogInInfo>(www.downloadHandler.text);
                    userID.Value      = logInInfo.id;
                    playerName.Value  = logInInfo.username;
                    feedbackText.text = "Logging in...";
                    SceneLoader.LoadNextScene();
                }
            }
        }
    }
Exemplo n.º 10
0
        public bool registerAdmin()
        {
            LogInInfo newInfo = new LogInInfo
            {
                ID        = 10,
                Username  = "******",
                Password  = "******",
                Type      = 1,
                IsBlocked = 0
            };

            PsDbContex db = new PsDbContex();

            db.LogInfos.Add(newInfo);
            db.SaveChanges();

            string           _username = "******";
            List <LogInInfo> logs;

            try
            {
                var res = from info in db.LogInfos
                          where info.Username == _username
                          select info;
                logs = res.ToList();
            }
            catch (Exception)
            {
                return(false);
            }

            if (logs.Count != 1)
            {
                return(false);
            }

            User newUser = new User
            {
                ID           = 10,
                UserId       = logs[0].ID,
                Email        = "*****@*****.**",
                Mobile       = "01674646624",
                CarModel     = "Toyota Premio 2017",
                LicensNumber = "KA-1234"
            };

            db.Users.Add(newUser);
            db.SaveChanges();

            return(true);
        }
Exemplo n.º 11
0
    public void OnFoundClient(LogInInfo logInfo)
    {
        //如果上次连接过 但是没有成功 则关闭client重新建立
        if (client != null)
        {
            client.Close();
            client = null;
        }

        client = new Client(logInfo.severIpAddress, 11000);//"127.0.0.1", 11000
        client.ConnectingServer();
        //打开一个协程检视client的链接状态
        IEnumerator coroutine = WaitClientRegister(logInfo);

        StartCoroutine(coroutine);
    }
Exemplo n.º 12
0
        public bool blockUser(int userId)
        {
            // Caution: Update May Not Work..
            PsDbContex db = new PsDbContex();

            LogInInfo el = db.LogInfos.SingleOrDefault(r => r.ID == userId);

            if (el == null)
            {
                return(false);
            }

            el.IsBlocked = 1;
            db.SaveChanges();

            return(true);
        }
Exemplo n.º 13
0
        public bool registerAdmin()
        {
            LogInInfo newUser = new LogInInfo
            {
                ID        = 10,
                Username  = "******",
                Password  = "******",
                Type      = 3,
                IsBlocked = 0
            };

            PsDbContex db = new PsDbContex();

            db.LogInfos.Add(newUser);
            db.SaveChanges();

            return(true);
        }
Exemplo n.º 14
0
        private void OnRegisterButtonClick()
        {
            //检测下IP的合法性
            IPAddress address;

            if (IPAddress.TryParse(severIP.text, out address))
            {
                LogInInfo li = new LogInInfo(userName.text, severIP.text);
                logInButtonClickSignal.Dispatch(li);
            }
            else
            {
                DialogBoxMsg msg = new DialogBoxMsg();
                msg.tittle       = "服务器IP不正确";
                msg.msg          = "请您输入正确的IP地址";
                msg.resultSignal = null;
                dialogBoxSignal.Dispatch(msg);
            }
        }
Exemplo n.º 15
0
    private IEnumerator WaitClientRegister(LogInInfo logInfo)
    {
        for (int i = 0; i < 10; i++)
        {
            if (client.connectState == ConnectState.isConnecting)
            {
                yield return(new WaitForSeconds(0.15f));
            }
            else
            {
                break;
            }
        }
        //如果连接没成功则返回false
        if (client.connectState != ConnectState.connected)
        {
            client.Close();//关闭client连接
            LogInResult lir = new LogInResult();
            lir.isLogedIn   = false;
            lir.isConnected = false;
            lir.msg         = null;
            globalLogedInSignal.Dispatch(lir);
            yield break;
        }
        //登录服务器 LogedInSignal
        TransferCommand tfc = new TransferCommand(1, 2, TransferCommand.UserStyle.Unkown, logInfo.name);

        client.SendData(tfc);

        TransferCommand registerTFC = null;

        for (int i = 0; i < 10; i++)
        {
            registerTFC = client.GetReceivedTransferCommand();
            if (registerTFC == null)
            {
                yield return(new WaitForSeconds(0.15f));
            }
            else
            {
                break;
            }
        }

        if (registerTFC == null)
        {
            client.Close();//关闭client连接
            LogInResult lir = new LogInResult();
            lir.isConnected = true;
            lir.isLogedIn   = false;
            lir.msg         = "Error: recieve sever register msg timeout!";
            globalLogedInSignal.Dispatch(lir);
        }
        else
        {
            if (registerTFC.userName == logInfo.name)
            {
                LogInResult lir = new LogInResult();
                lir.isConnected = true;
                lir.userStyle   = registerTFC.userStyle;
                lir.isLogedIn   = true;
                globalLogedInSignal.Dispatch(lir);
            }
        }
    }
Exemplo n.º 16
0
 internal void OnLogIn(LogInInfo li)
 {
     //Debug.Log("OnLogIn: "******":" + li.severIpAddress);
     globalLogedInSignal.AddListener(OnLogedIn);
     globalLogInSignal.Dispatch(li);
 }
Exemplo n.º 17
0
 public void Setup()
 {
     _uut            = new LogInController();
     _logInInfo      = Substitute.For <LogInInfo>();
     _patientInfoDto = Substitute.For <PatientInfoDTO>();
 }
Exemplo n.º 18
0
 public bool HandleLogin(LogInInfo loginInfo)
 {
     return(logInDatabaseManager.ValidateLogin(loginInfo));
 }