Пример #1
0
        public static AuthenticationProfile Login(string emailAddress, string password)
        {
            var userAuthInfo = new UserAuthInfo {
                EmailAddress = emailAddress, Password = password
            };
            var userInfo = UserAuthenticator.Authenticate(userAuthInfo, AuthenticationScope.Tenant);

            return(userInfo);
        }
Пример #2
0
        private void doLoginIn_Click(object sender, EventArgs e)
        {
            //var fuser = new UserAuthenticator().Authenticate("mkabila", 123456);
            //AppInstance.Instance.CurrentUser = fuser;
            //StartActivity(typeof(LauncherActivity));
            //return;

            var tusername = FindViewById <EditText>(Resource.Id.tUserName);
            var tpasscode = FindViewById <EditText>(Resource.Id.tPassCode);

            var uname = tusername.Text;

            if (string.IsNullOrWhiteSpace(uname) || string.IsNullOrWhiteSpace(tpasscode.Text))
            {
                showDialog("Alert", "UserName and Passcode are both required");
                return;
            }

            var passcode = Convert.ToInt32(tpasscode.Text);

            var authenticator = new UserAuthenticator();
            var user          = authenticator.Authenticate(uname, passcode);

            if (user != null)
            {
                //we set this as the logged in user
                AppInstance.Instance.CurrentUser = user;
                if (user.User.UserId == Constants.ADMIN_USERNAME)
                {
                    //we show the admin view
                    StartActivity(typeof(SystemConfigActivity));
                }
                else
                {
                    //load the main view and update current user options
                    if (AppInstance.Instance.Configuration != null)
                    {
                        StartActivity(typeof(LauncherActivity));
                    }
                    else
                    {
                        showDialog("Login Unsuccessful",
                                   "Please log in as Admin and set up the device");
                    }
                }
            }
            else
            {
                showDialog("Login Unsuccessful", "Could not log you in. Please check input supplied");
            }
        }
Пример #3
0
        protected override UserAuthenticationDto ValidateCredentials(string name,
                                                                     string passwordHash, string customData, out string userData)
        {
            UserAuthenticationDto user = null;

            userData = null;
            UserDto authUser = UserAuthenticator.Authenticate(name, passwordHash);

            if (authUser != null)
            {
                user      = new UserAuthenticationDto();
                user.Name = authUser.Login;
                userData  = authUser.Name;
            }
            return(user);
        }
Пример #4
0
 /// <summary>
 /// Handles a login message from the client.
 /// If the user can be authenticated a User instance will be created, and the client will be able to log in.
 /// If the user cannot be authenticated, an error message will be send to the client. Indicating the username or password were wrong.
 /// </summary>
 /// <param name="message"></param>
 private void HandleLoginMessage(LoginMessage message)
 {
     Console.WriteLine("Handling Login");
     User = UserAuthenticator.Authenticate(message.Username, message.Password, _userHandler);
     if (User == null)
     {
         SendMessage(new ErrorMessage("Login Failed"));
     }
     else
     {
         SendMessage(new OkLoginMessage());
         _joinSession(message.SessionId, this);
         SendMessage(new OkLoginMessage());
         Session.BroadCastChatMessage("Server", $"Welcome {message.Username}");
     }
 }
Пример #5
0
        public void SimpleAuthLoginTest()
        {
            var emailAddress = Mozu.Api.Test.Helpers.Environment.GetConfigValueByEnvironment("devOwnerEmail");
            var password     = Mozu.Api.Test.Helpers.Environment.GetConfigValueByEnvironment("devOwnerPassword");

            var userAuthInfo = new UserAuthInfo {
                EmailAddress = emailAddress, Password = password
            };

            var userInfo = UserAuthenticator.Authenticate(userAuthInfo, AuthenticationScope.Developer);

            Assert.IsNotNull(userInfo);
            Assert.IsNotNull(userInfo.AuthTicket);
            Assert.IsNotNull(userInfo.AuthTicket.AccessToken);

            if (userInfo.ActiveScope == null)
            {
                userInfo = UserAuthenticator.SetActiveScope(userInfo.AuthTicket, userInfo.AuthorizedScopes.First());

                Assert.IsNotNull(userInfo);
                Assert.IsNotNull(userInfo.ActiveScope);
            }
        }