Ejemplo n.º 1
0
 /// <summary>
 /// Instantiate a user with a predefined profile
 /// </summary>
 /// <param name="Login">User's unique login name</param>
 /// <param name="Email">User's email address</param>
 /// <param name="FirstName">User's first name</param>
 /// <param name="LastName">User's last name</param>
 /// <param name="MobilePhone">User's phone number</param>
 /// <param name="SecondaryEmail">User's secondary email</param>
 public User(string Login, string Email, string FirstName, string LastName, string MobilePhone = null, string SecondaryEmail = null)
 {
     Profile = new UserProfile(){
         Login = Login,
         Email = Email,
         FirstName = FirstName,
         LastName = LastName,
         MobilePhone = MobilePhone,
         SecondaryEmail = SecondaryEmail
     };
 }
Ejemplo n.º 2
0
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                string apiToken = ConfigurationManager.AppSettings["okta:ApiToken"];
                var    apiUrl   = new System.Uri(ConfigurationManager.AppSettings["okta:ApiUrl"]);

                Okta.Core.Models.UserProfile oktaUserProfile = new Okta.Core.Models.UserProfile()
                {
                    Login     = model.UserName,
                    FirstName = model.FirstName,
                    LastName  = model.LastName,
                    Email     = model.Email
                };

                LoginCredentials oktaLoginCred = new LoginCredentials();
                oktaLoginCred.Password.Value = model.Password;

                User oktaSendUser = new User();
                oktaSendUser.Profile     = oktaUserProfile;
                oktaSendUser.Credentials = oktaLoginCred;

                try
                {
                    OktaClient oktaClient     = new OktaClient(apiToken, apiUrl);
                    User       oktaReturnUser = oktaClient.GetUsersClient().Add(oktaSendUser, activate: true);
                    ViewBag.Status = "Status: " + oktaReturnUser.Status;
                    ViewBag.UserId = "User Id: " + oktaReturnUser.Id;
                }
                catch (OktaException e)
                {
                    Console.WriteLine("error: " + e.Message);
                    ModelState.AddModelError("", e.ErrorSummary);
                }
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Ejemplo n.º 3
0
 public User()
 {
     Profile = new UserProfile();
     Credentials= new LoginCredentials();
 }