コード例 #1
0
        internal void Login(string password)
        {
            try
            {
                if (Id == null || password == "")
                {
                    throw new ArgumentException("אתה צריך למלא את כל השדות");
                }
                else
                {
                    Password = password;

                    User = LoginM.GetUser(Id);
                    if (Password == User.Password && User.Type.ToString() == "מנהל")
                    {
                        IControlManage.User = User;
                        (App.Current as App).navigation.ShowControls("AdministratorUC");
                    }
                    else if (Password == User.Password && User.Type.ToString() == "רופא")
                    {
                        IControlManage.User = User;
                        (App.Current as App).navigation.ShowControls("DoctorUC");
                    }
                    else
                    {
                        throw new ArgumentException("סיסמה לא נכונה");
                    }
                }
            }
            catch (Exception e)
            {
                (App.Current as App).navigation.MainWindows.comments.Text = e.Message.ToString();
            }
        }
コード例 #2
0
        public ActionResult Login(LoginM model)
        {
            if (ModelState.IsValid)
            {
                var dao    = new UserDAO();
                var result = dao.Login(model.Username, Encryptor.MD5Hash(model.Password));
                if (result == 1)
                {
                    var user        = dao.GetById(model.Username);
                    var userSession = new UserLogin();
                    userSession.Username      = user.Username;
                    userSession.Customer_ID   = user.Customer_ID;
                    userSession.Email         = user.Email;
                    userSession.Customer_Name = user.Customer_Name;

                    Session.Add(CommonConstants.USER_SESSION, userSession);


                    return(Redirect("/"));
                }

                else if (result == 0)
                {
                    ViewBag.Error = "Invalid username or password, try again.";
                    //ModelState.AddModelError("", "Tài khoản không tồn tại.");
                }
                else if (result == -2)
                {
                    ViewBag.Error = "Invalid username or password, try again.";
                    //ModelState.AddModelError("", "Mật khẩu không đúng.");
                }
            }

            return(View(model));
        }
コード例 #3
0
        public ActionResult Login(LoginM model)
        {
            // Model validation.
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            // Authentication validation.
            UsersRepo usersRepo = new UsersRepo();
            User      user      = usersRepo.GetFirstOrDefault(u => u.Username == model.Username &&
                                                              u.Password == model.Password);

            // In case of invalid authentication.
            if (user == null)
            {
                ModelState.AddModelError("authFailed", "Invalid username or password!");

                return(View(model));
            }

            // In case of valid authentication.
            Session["loggedUser"] = user;

            return(RedirectToAction("Index", "Home"));
        }
コード例 #4
0
ファイル: LoginC.cs プロジェクト: ARIFCAHYO09/aplikasi_parkir
        public static void masuk(string a, string b)
        {
            LoginM.IsUserValid(a, b);
            string c = "Login sebagai : ";
            string d = "privillage : ";

            if (LoginM.priv == "0")
            {
                LoginM.priv = "user";
            }
            if (LoginM.priv == "1")
            {
                LoginM.priv = "admin";
            }

            string e = string.Concat(c, a + Environment.NewLine, d, LoginM.priv);

            if (LoginM.IsUserValid(a, b) == true)
            {
                MessageBox.Show(e);
                Form.ActiveForm.Hide();
                Parkir pa = new Parkir();
                pa.Show();
            }
            else
            {
                MessageBox.Show("error username atau password salah");
            }
        }
コード例 #5
0
        public async Task <IActionResult> Login(LoginM model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            //istifadecini tap
            var user = await Context.Users.Where(c => c.Username == model.Username).FirstOrDefaultAsync();

            if (user == null)
            {
                ModelState.AddModelError("", "Belə bir istifadəçi yoxdur.");
                return(View(model));
            }

            //parolu yoxla
            byte[] salt   = Encoding.UTF8.GetBytes(user.Salt);
            bool   result = PasswordHasher.Check(model.Password, salt, user.PasswordHash);

            if (result)
            {
                await Identity.SignInAsync(user, HttpContext);

                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                ModelState.AddModelError("", "Istifadəçi adı və ya şifrə yanlışdır.");
                return(View(model));
            }
        }
コード例 #6
0
 /// <summary>
 ///   请求登入回调
 /// </summary>
 public static void RecvMsgLS2CLLoginReply(eMsgTypes Type, object Info)
 {
     if (Info == null)
     {
         return;
     }
     g_LSLogin = Info as ProtoMsg.MsgCl2lgLoginReply;
     IGGDebug.Log("连接登入服务器成功");
     // 请求链接GS
     LoginM.ConnectGameServer();
 }
コード例 #7
0
        private void Btnlogin_Click(object sender, EventArgs e)
        {
            if (LoginM.IsUserValid(TextboxName.Text, TextboxPws.Text))
            {
                this.Hide();

                Parkir ss = new Parkir();
                ss.Show();
            }
            else
            {
                MessageBox.Show("GAGAl LOGIN");
            }
        }
コード例 #8
0
 protected internal async void Start()
 {
     await Task.Run(async() =>
     {
         try
         {
             using (me = new MedicalModel(ConfigurationManager.Connect()))
             {
                 await me.Database.Connection.OpenAsync();
                 LoginM.ExistUsers = me.accountdata.Where(a => a.DeletedAD != true).Select(a => a.UserNameAD).ToList();
             }
             workingConn = true;
             if (ConfigurationManager.ConfigurationManagerM.FacilityId != string.Empty)
             {
                 GlobalVM.GlobalM.CompanyId = Convert.ToInt32(ConfigurationManager.ConfigurationManagerM.FacilityId);
             }
         }
         catch (Exception ex)
         {
             Log.WriteException(ex);
             workingConn = false;
         }
         finally
         {
             if (!workingConn)
             {
                 LoginM.ExistUsers = new List <string> {
                     ConfigurationManager.ConfigurationManagerM.SecurityUsername
                 }
             }
             ;
         }
     }, CancellationToken.None).ContinueWith(async task =>
     {
         LoginM.AcceptChanges();
         if (!workingConn)
         {
             dialog         = new Dialog(true, "Nem sikerült elérni az adatbázist", async() => await Utilities.Loading.Hide());
             dialog.content = new TextBlock("Adatbáziskapcsolat nélkül nem lehet megfelelően használni az alkalmazást\n" +
                                            "Első használat alkalmával be kell konfigurálni az adatbázis kapcsolatot\n" +
                                            "Kérjük jelezze a problémát a rendszergazdának");
             dialog.Start();
             (GlobalVM.StockLayout.verticalMenu.Children[0] as StockVerticalMenuItem).IsEnabledTrigger = false;
         }
         else
         {
             await Utilities.Loading.Hide();
         }
     }, TaskScheduler.FromCurrentSynchronizationContext());
 }
コード例 #9
0
        public async Task <IActionResult> Login(LoginM model)
        {
            if (ModelState.IsValid)
            {
                User user = await db.Users.FirstOrDefaultAsync(u => u.Phone == model.Phone && u.Password == model.Password);

                if (user != null)
                {
                    await Authenticate(model.Phone); // аутентификация

                    return(RedirectToAction("Index", "Home"));
                }
                ModelState.AddModelError("", "Некорректные логин и(или) пароль");
            }
            return(View(model));
        }
コード例 #10
0
        public ActionResult ChkUserData(LoginM model)
        {
            LoginR resultMode = CallApi <LoginM, LoginR>("Api/Login/ChkUserData", model);

            if (resultMode == null)
            {
                resultMode          = new LoginR();
                resultMode.IS_Error = "Y";
                resultMode.MSG      = "使用者帳號無法驗證,請重新輸入";
            }

            DataContractJsonSerializer json = new DataContractJsonSerializer(resultMode.GetType());

            using (MemoryStream ms = new MemoryStream())
            {
                json.WriteObject(ms, resultMode);
                string ResultJson = Encoding.UTF8.GetString(ms.ToArray());
                return(Json(ResultJson));
            }
        }
コード例 #11
0
ファイル: Login.aspx.cs プロジェクト: oscarrene380/GestionRH
    protected void btnEntrar_Click(object sender, EventArgs e)
    {
        string usuario  = txtUsuario.Text;
        string password = txtPassword.Text;

        if (conexion.conectar())
        {
            conexion.cerrar();
            EstadoPermisos.PermisosCaducados(fecha);
            EstadoPermisos.ActivarPermiso(fecha);
            if (LoginM.autenticar(usuario, password) == true)
            {
                Session["User"]     = usuario;
                Session["TUsuario"] = LoginM.tipoUser(usuario);
                switch (LoginM.tipoUser(usuario))
                {
                case 1:
                    Response.Redirect("Prueba.aspx");
                    break;

                case 2:
                    Response.Redirect("PruebaAdmin.aspx");
                    break;

                case 3:
                    Response.Redirect("PruebaGerente.aspx");
                    break;
                }
            }
            else
            {
                Response.Write("<script>alert('Usuario o Contraseña no son validos!');</script>");
            }
        }
        else
        {
            Response.Write("<script>alert('No se puede conectar, intente más tarde!.');</script>");
        }
    }
コード例 #12
0
        public async Task <IActionResult> ExternalLoginConfirmation(LoginM model, string returnUrl = null)
        {
            if (User.IsSignedIn())
            {
                return(RedirectToAction(nameof(InitialController.timer), "Initial"));
            }

            if (ModelState.IsValid)
            {
                // Get the information about the user from the external login provider
                var info = await _loginManager.GetExternalLoginInfoAsync();

                if (info == null)
                {
                    return(View("ExternalLoginFailure"));
                }
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email
                };
                var result = await _securityManager.CreateAsync(user);

                if (result.Succeeded)
                {
                    result = await _securityManager.AddLoginAsync(user, info);

                    if (result.Succeeded)
                    {
                        await _loginManager.SignInAsync(user, isPersistent : false);

                        _logger.LogInformation(6, "User created an account using {Name} provider.", info.LoginProvider);
                        return(RedirectToLocal(returnUrl));
                    }
                }
                AddErrors(result);
            }

            ViewData["ReturnUrl"] = returnUrl;
            return(View(model));
        }
コード例 #13
0
        public ActionResult SetLogin(LoginM model)
        {
            LoginR resultMode = CallApi <LoginM, LoginR>("Api/Login/SetLogin", model);

            if (resultMode == null)
            {
                resultMode          = new LoginR();
                resultMode.IS_Error = "Y";
            }
            if (resultMode.IS_Error == "N")
            {
                Session.Add("LoginModel", resultMode);
            }

            DataContractJsonSerializer json = new DataContractJsonSerializer(resultMode.GetType());

            using (MemoryStream ms = new MemoryStream())
            {
                json.WriteObject(ms, resultMode);
                string ResultJson = Encoding.UTF8.GetString(ms.ToArray());
                return(Json(ResultJson));
            }
        }
コード例 #14
0
        public ActionResult RegisteredVaild(string VaildID, string IsVue = "N")
        {
            LoginR resultMode = new LoginR();

            TempData["IsVue"] = IsVue;
            if (VaildID == null)
            {
                if (Session["LoginModel"] != null)
                {
                    resultMode = Session["LoginModel"] as LoginR;
                }
                else
                {
                    resultMode.MSG = "無法導向網頁";
                }
                return(View(resultMode));
            }
            else if (VaildID == "Vaild")
            {
                resultMode.MSG = TempData["Msg"].ToString();
                return(View("~/Views/Login/RegisteredVaild.cshtml", resultMode));
            }

            LoginM model = new LoginM();

            model.VaildID = VaildID;
            resultMode    = CallApi <LoginM, LoginR>("Api/Login/VaildRegistered", model);

            if (resultMode == null)
            {
                resultMode          = new LoginR();
                resultMode.IS_Error = "Y";
            }

            return(View(resultMode));
        }
コード例 #15
0
 public LoginVM()
 {
     ErrorVisible = Visibility.Hidden;
     LoginModel   = new LoginM();
 }
コード例 #16
0
 public LoginVM()
 {
     CurrentModel = new LoginM();
 }
コード例 #17
0
        public async Task <ActionResult> Login(LoginM data)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            model = data;
            client.BaseAddress = CommonData.ApiUrl;

            var jsonString = JsonConvert.SerializeObject(model);
            var content    = new StringContent(jsonString, Encoding.UTF8, "application/json");
            IEnumerable <string> found;

            try
            {
                HttpResponseMessage responseFromRequest = await client.PostAsync("api/ExternalLogin", content);

                if (responseFromRequest != null)
                {
                    System.Net.Http.Headers.HttpResponseHeaders headers = responseFromRequest.Headers;
                    if (headers.Contains("Found"))
                    {
                        if (headers.TryGetValues("Found", out found) && found.ToArray()[0] == "true")
                        {
                            if (headers.Contains("EmployeeID"))
                            {
                                EmployeeID              = headers.GetValues("EmployeeID").ToString();
                                Session["UserName"]     = model.UserName;
                                Session["SafetyLogged"] = true;
                                return(RedirectToAction("", ""));
                            }
                            else if (headers.Contains("WrongPassword"))
                            {
                                ViewBag.Error = "Password doesn't match.";
                                return(RedirectToAction("Login", "Login"));
                            }
                        }
                        else if (headers.TryGetValues("Found", out found) && found.ToArray()[0] == "false")
                        {
                            if (headers.Contains("UserNotFound"))
                            {
                                ViewBag.Error = "Username not found";
                                return(RedirectToAction("", ""));
                            }
                            else if (headers.Contains("WrongPassword"))
                            {
                                ViewBag.Error = "Password incorrect";
                                return(RedirectToAction("", ""));
                            }
                        }
                    }
                }
                ViewBag.Error = "Internal issue, please try again later.";
                return(RedirectToAction("", ""));
            }
            catch (Exception exc)
            {
                ViewBag.Message = "Internar server error, but you'll be redirected anyway." + exc.Message;
                return(RedirectToAction("Index", "Home"));
            }
            //return View();
        }
コード例 #18
0
 private void loadScene()
 {
     LoginM.LoadServerListFromText(ConstantData.ServerListSavePath + ConstantData.ServerListFile);
     SceneM.Load(LoginScene.GetSceneName());
 }
コード例 #19
0
ファイル: NetReConnet.cs プロジェクト: 741645596/Golf
 public static void HideReConnect()
 {
     LoginM.ConnectLoginServer();
 }
コード例 #20
0
 protected internal LoginVM()
 {
     LoginM = new LoginM();
     Start();
 }
コード例 #21
0
ファイル: NetReConnet.cs プロジェクト: 741645596/Golf
 // 显式重连
 public static void ShowReConnect()
 {
     LoginM.ConnectLoginServer();
 }