예제 #1
0
        public ActionResult Login(FormCollection collection)
        {
            using (ServiceHelper serviceHelper = new ServiceHelper())
            {
                try
                {
                    LoginViewModel lvm = new LoginViewModel
                    {
                        Username = Convert.ToString(collection["Username"]),
                        Password = Convert.ToString(collection["Password"])
                    };

                    AuthServiceClient authClient = serviceHelper.GetAuthServiceClient();

                    if (authClient.Login(lvm.Username, lvm.Password))
                    {
                        AuthHelper.Login(lvm);
                        lvm.Id = serviceHelper.GetCustomerServiceClient().FindCustomerByUsername(lvm.Username).Id;
                    }
                    else
                    {
                        throw new InvalidLoginException();
                    }

                    return(RedirectToAction("Index", "Home"));
                }
                catch
                {
                    return(View());
                }
            }
        }
예제 #2
0
        private async void LogInButton_OnClick(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(LoginTextBox.Text) || string.IsNullOrWhiteSpace(PasswordTextBox.Password))
            {
                await this.ShowMessageAsync("Warning", "Please fill login and password fields");

                return;
            }

            var user = _authService.Login(LoginTextBox.Text, PasswordTextBox.Password);

            if (user == null)
            {
                await this.ShowMessageAsync("Warning", "You entered incorrect login or password");

                return;
            }

            switch (user.Role)
            {
            case UserRoles.Doctor:
                var doctor = _doctorService.GetDoctor(user.Id);

                new DoctorWindow(doctor).Show();
                Close();
                break;

            case UserRoles.Patient:
                var patient = _patientService.GetPatient(user.Id);

                new PatientWindow(patient).Show();
                Close();
                break;
            }
        }
예제 #3
0
        public UserContract Login(string userName, string password)
        {
            AuthServiceClient client  = new AuthServiceClient();
            UserContract      retUser = client.Login(userName, password);

            client.Close();
            if (retUser != null)
            {
                CreateCookie(userName, true);
            }
            return(retUser);
        }
예제 #4
0
        public JsonResult Login(Qz.GPS.DirectService.Parameter.User.Login user)
        {
            SsoService.AuthServiceClient auth = new AuthServiceClient();

            var token = auth.Login(user.Account, user.Password);

            return Json(
                new Qz.Core.Entity.Response()
                {
                    Message = token
                }
            );
        }
예제 #5
0
 public bool Login(string username, string password)
 {
     using (AuthServiceClient authClient = _serviceManager.GetAuthServiceClient())
     {
         if (authClient.Login(username, password))
         {
             var cookie = _cookieSetup.CreateEncryptedAuthenticationCookie("roh", "han"); //Cookie is encrypted using AES(using machineKey and transmitted to the client. Key is on server. Cannot realistically be decrypted. Password not transmitted in this case
             System.Web.HttpContext.Current.Response.Cookies.Add(cookie);
             _sessionManager.SetLoggedInSession(new CustomPrincipalSerializeModel {
                 FirstName = "John", LastName = "Doe"
             });
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
예제 #6
0
        public ActionResult Login(string userName, string uPassword)
        {
            bool check = UserClient.Login(userName, uPassword);
            int  id    = 0;

            ServicePointManager.ServerCertificateValidationCallback = (obj, certificate, chain, errors) => true;
            AuthServiceClient authClient = new AuthServiceClient();
            var isLoggedIn = authClient.Login(userName, uPassword);

            if (isLoggedIn)
            {
                id = UserClient.GetUserByUserName(userName).ID;

                SecurityServiceClient client = new SecurityServiceClient("WSHttpBinding_ISecurityService");
                client.ClientCredentials.UserName.UserName = userName;
                client.ClientCredentials.UserName.Password = uPassword;
                var data = client.GetData(1337);
            }

            return(RedirectToAction("Index", new { id = id }));
        }
예제 #7
0
        public async Task <User> AuthenticateAsync(string username, string password)
        {
            try
            {
                if (AreCredentialsAvaible() && HasValidCredentialsAvaible())
                {
                    return(GetStoredUser());
                }

                var encryptedPassword = crypto.Encrypt(password);

                var userModel = await authServiceClient.Login(new UserModel { Email = username, Password = encryptedPassword });

                var user = new User
                {
                    Id          = userModel.Id,
                    Email       = userModel.Email,
                    Password    = password,
                    ChangeStamp = DateTime.Now,
                    LastApiCall = DateTime.Now,
                    Token       = userModel.Token
                };

                await SaveOrUpdateUser(user);

                return(user);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                isAuthenticated = true;

                OnAuthenticationChanged?.Invoke(this, EventArgs.Empty);
            }
        }
예제 #8
0
        private void butLoggin_Click(object sender, RoutedEventArgs e)
        {
            String login    = TBoxLogin.Text;
            String password = TBoxPass.Password;

            AuthServiceClient client = new AuthServiceClient();

            String sessionId = client.Login(login, password);

            if (sessionId != null)
            {
                App.Current.Properties[App.sessionPropertyName] = sessionId;
                App.Current.Properties[App.loginPropertyName]   = login;

                MainWindow mainWindow = new MainWindow();
                mainWindow.Show();
                this.Close();
            }
            else
            {
                LabelErrorLogin.Visibility = Visibility.Visible;
            }
        }
예제 #9
0
        static void Main(string[] args)
        {
            ServicePointManager.ServerCertificateValidationCallback = (obj, certificate, chain, errors) => true;
            AuthServiceClient authClient = new AuthServiceClient();
            var isLoggedIn = authClient.Login("*****@*****.**", "!# test password #!");

            if (isLoggedIn)
            {
                Console.WriteLine("AuthService authentication succeeded.");
                SocialAdServiceClient cl = new SocialAdServiceClient();
                cl.ClientCredentials.UserName.UserName = "******";
                cl.ClientCredentials.UserName.Password = "******";
                var data = cl.getData();
                var post = cl.GenerateTestPost("Hvis dette virker, er det rigtig spændende.");
                Console.WriteLine(data);
                Console.WriteLine(post.DatePosted);
                Console.WriteLine(post.Content);
                Console.ReadLine();
            }
            else
            {
                Console.WriteLine("Could not log in with AuthService.");
            }
        }
예제 #10
0
 private static void Login(string username, string password)
 {
     IsUserLoggedIn = authClient.Login(username, password);
 }