Пример #1
0
        /// <summary>
        /// Author: BOS Framework, Inc
        /// Description: Returns the "Login" view - The landing page of the application
        /// </summary>
        /// <returns></returns>
        public async Task <IActionResult> Index()
        {
            try
            {
                var response = await _multitenantService.GetGeneratedToken();

                //Check if user is authenticated then redirect him to clients
                if (User != null && User.Identity.IsAuthenticated)
                {
                    Guid UserId = UserId = new Guid(User.Claims.FirstOrDefault(c => c.Type == "UserId").Value);
                    if (UserId != null)
                    {
                        var status = await SetModulePermissions(UserId);

                        if (status != "")
                        {
                            await SignOut();
                        }
                        return(RedirectToAction("Index", "Dashboard"));
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.LogException("Auth", "Index", ex);

                dynamic model = new ExpandoObject();
                model.Message    = ex.Message;
                model.StackTrace = ex.StackTrace;
                return(View("ErrorPage", model));
            }
            //If the user is not logged in, then navigate him to the "Login" Page
            return(View("Index"));
        }
Пример #2
0
        /// <summary>
        /// Author: BOS Framework, Inc
        /// Description: Is triggered when the user gets to the Verification Link. If the slug is valid it shows the view to set/ reset the password, else just shows a message
        /// </summary>
        /// <param name="slug"></param>
        /// <returns></returns>
        public async Task <IActionResult> Reset(string slug, string set)
        {
            try
            {
                //Checking for a non-null slug
                if (!string.IsNullOrWhiteSpace(slug))
                {
                    if (_bosAuthClient == null)
                    {
                        var response = await _multitenantService.GetGeneratedToken();

                        SetAuthClient();
                    }

                    //Making an API call to verify if the Slug is still active and valid.
                    var result = await _bosAuthClient.VerifySlugAsync(slug);

                    if (result != null && result.StatusCode == System.Net.HttpStatusCode.Unauthorized)
                    {
                        return(RedirectToAction("SignOut", "Auth"));//Token Expired
                    }
                    if (result != null && result.IsSuccessStatusCode)
                    {
                        Guid userId = result.UserId;
                        ViewBag.UserId = userId;
                        ViewBag.Set    = set;
                        await _bosAuthClient.ConfirmUserEmailAddress(userId); //Making an API call to BOS to set the value true for email confirmation
                    }
                    else
                    {
                        //Display this message when the slug being used is either inactive or has expired. The BOS default expiration for a slug is 48 hours since the time of its generation
                        ViewBag.Message = "The link has either expired or is invalid. If you have just registered, then get in touch with your admistrator for a new password. If you have forgotten your password, retry again in some time.";
                    }

                    return(View("ResetPassword")); //Returning the ResetPassword View - where the end-user can set/ reset the password. The View then displays the form only if the slug is valid
                }
                else
                {
                    //Returning an error message when the slug is null
                    dynamic model = new ExpandoObject();
                    model.Message    = "The slug string cannot be empty or null.";
                    model.StackTrace = "";
                    return(View("ErrorPage", model));
                }
            }
            catch (Exception ex)
            {
                Logger.LogException("Password", "Reset", ex);

                dynamic model = new ExpandoObject();
                model.Message    = ex.Message;
                model.StackTrace = ex.StackTrace;
                return(View("ErrorPage", model));
            }
        }