Example #1
0
        public async void WhenICallAGetMethodWithTheTokenEmbeddedInTheRequest()
        {
            var oauthBaseHost    = _config.SelectToken("endpoint")["authEndpoint"].ToString();
            var requestParamsObj = JObject.Parse(_config.SelectToken("authBodyParams").ToString());
            IAuthenticationClass restApiAuthentication = new AuthenticationClass(oauthBaseHost, requestParamsObj);

            token = await restApiAuthentication.GetOauthAuthenticationAsync();

            SetHttpMethod(Method.GET);

            SetHeaderToken(token);
        }
Example #2
0
        public ActionResult Authentication(AuthenticationClass model)
        {
            //if ((model.UserName == "james") && (model.Password == "fulcrum#1"))
            //{
            //    Session["UserId"] = Convert.ToString(1);
            //    return RedirectToAction("UserDetails");
            //}
            //else
            //{
            //    return View();
            //}

            DAL datalogic = new DAL();
            int UserId    = 0;

            try
            {
                UserId = datalogic.Auntheticate(model);
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(string.Empty, ex.Message);
            }

            if (UserId != 0)
            {
                Session["UserId"] = Convert.ToString(UserId);
                return(RedirectToAction("DisplayDashBoard", "DashBoard"));
            }
            else
            {
                TempData["message"] = "Invalid User Name or Password";
                //ModelState.AddModelError(string.Empty, );
                return(View(model));
            }
        }
    protected void uxLogin_Click(object sender, EventArgs e)
    {
        /*
         * The system against which the user will be authenticated.
         */
        var AuthenticationSystem = new AuthenticationClass();

        /*
         * Attempt to authenticate the user using third-party system.
         */
        bool authenticated = AuthenticationSystem.Authenticate(uxUsername.Text, uxPassword.Text);

        if (authenticated)
        {
            /*
             * The class used to login/create Ektron proxy users.
             */
            var EktronProxyUserManager = new ThirdPartyUserManagement();

            /*
             * Attempt login.
             */
            bool ektronLoginSuccess = EktronProxyUserManager.AttemptProxyUserLogin(AuthenticationSystem.AuthenticationSystemId, uxUsername.Text);

            /*
             * If login attempt failed...
             */
            if (!ektronLoginSuccess)
            {
                /*
                 * Create new user from auth system.
                 *
                 * You may want to have the user complete a more robust profile before this step.
                 * I simply chose the path of least resistance here to illustrate one of several
                 * possible scenarios.
                 */
                bool ektronUserCreated = EktronProxyUserManager.CreateEktronProxyUser(AuthenticationSystem.AuthenticationSystemId, uxUsername.Text);

                /*
                 * If we were able to create the user...
                 */
                if (ektronUserCreated)
                {
                    /*
                     * Attempt to login the newly created user.
                     */
                    ektronLoginSuccess = EktronProxyUserManager.AttemptProxyUserLogin(AuthenticationSystem.AuthenticationSystemId, uxUsername.Text);
                }
            }

            if (ektronLoginSuccess)
            {
                /*
                 * Redirect to ensure the cookie is properly set and to clear any postback data.
                 */
                Response.Redirect(Request.RawUrl);
            }
            else
            {
                // show error message
            }
        }
    }