Esempio n. 1
0
 /// <summary>
 /// Authorize the users access from application (Logout)
 /// </summary>
 public static void Authorize()
 {
     try
     {
         var ticket = ManageUserModelHelper.GetFormsAuthenticationTicket();
         if (ticket != null)
         {
             var idKey = ticket.IdKey();
             if (idKey != Guid.Empty)
             {
                 using (var db = new DbContextHelper())
                 {
                     User user = ManageUserModelHelper.GetUser(db, idKey);
                     if (user != null)
                     {
                         user.UserStatusEnum = UserStatus.Offline;
                         db.SaveChanges();
                     }
                 } //end using
             }     //end if
         }         //end if
         FormsAuthentication.SignOut();
     }
     catch (Exception ex)
     {
         LogHelper.LogFatalError("UserModelHelper.Authorize", ex);
         throw ex;
     }
 }
Esempio n. 2
0
        void AuthenticateRequest(object sender, EventArgs e)
        {
            var ticket = ManageUserModelHelper.GetFormsAuthenticationTicket();

            if (ticket != null)
            {
                HttpContext.Current.User = new GenericPrincipal(new FormsIdentity(ticket), ticket.Roles().ToArray());
            }
        }
Esempio n. 3
0
        public virtual ActionResult Edit(string idKey)
        {
            var model = ManageUserModelHelper.GetUserModelForEdit(idKey);

            if (model == null)
            {
                return(this.RedirectToAction <UsersController>(a => a.Index()));
            }
            return(View(model));
        }
Esempio n. 4
0
 private static UserModel GetModelFromUser(User user)
 {
     try
     {
         return(ManageUserModelHelper.GetModelFromUser(user));
     }
     catch (Exception ex)
     {
         LogHelper.LogFatalError("UserModelHelper.GetModelFromUser", ex);
         throw ex;
     }
 }
Esempio n. 5
0
        public static HomeModel GetHomeModel()
        {
            var model  = new HomeModel();
            var quotes = QuoteModelHelper.GetAll();

            model.Quote = quotes.GetRandom();

            var ticket = ManageUserModelHelper.GetFormsAuthenticationTicket();

            if (ticket != null)
            {
                model.UserIdKey = ticket.IdKey();
            }

            return(model);
        }
Esempio n. 6
0
        public static EventModel GetEventCalendarModel()
        {
            var model  = new EventModel();
            var ticket = ManageUserModelHelper.GetFormsAuthenticationTicket();

            if (ticket != null)
            {
                model.UserIdKey = ticket.IdKey();
            }

            model.PageTitle       = "Holy Angels Event Calendar";
            model.MetaDescription = "";
            model.MetaKeywords    = "";
            model.MetaSubject     = "";

            return(model);
        }
Esempio n. 7
0
        public static HomeModel GetChristianityModel()
        {
            var model = GetHomeModel();

            var ticket = ManageUserModelHelper.GetFormsAuthenticationTicket();

            if (ticket != null)
            {
                model.UserIdKey = ticket.IdKey();
            }

            model.PageTitle       = "Holy Angels African-American Christianity";
            model.MetaDescription = "";
            model.MetaKeywords    = "";
            model.MetaSubject     = "";

            return(model);
        }
Esempio n. 8
0
        public static HomeModel GetAboutModel()
        {
            var model = GetHomeModel();

            var ticket = ManageUserModelHelper.GetFormsAuthenticationTicket();

            if (ticket != null)
            {
                model.UserIdKey = ticket.IdKey();
            }

            model.PageTitle       = "About Holy Angels Church";
            model.MetaDescription = "";
            model.MetaKeywords    = "";
            model.MetaSubject     = "";

            return(model);
        }
Esempio n. 9
0
        internal static object GetPrivacyModel()
        {
            var model = GetHomeModel();

            var ticket = ManageUserModelHelper.GetFormsAuthenticationTicket();

            if (ticket != null)
            {
                model.UserIdKey = ticket.IdKey();
            }

            model.PageTitle       = "Holy Angels Church Privacy Policy";
            model.MetaDescription = "";
            model.MetaKeywords    = "";
            model.MetaSubject     = "";

            return(model);
        }
Esempio n. 10
0
        /// <summary>
        /// Authorize the current user on the site. Authenication occurs via Facebook app (signin)
        /// </summary>
        /// <param name="model">User model</param>
        /// <param name="status">status of authorizing the user</param>
        /// <param name="code">Facebook Oauth code used to retrieve a Facebook access token</param>
        /// <returns></returns>
        /// <remarks>Requires the code to be set on the model. This is used to retrieve a Facebook access token</remarks>
        public static bool Authorize(this UserModel model, string code, out Status status)
        {
            try
            {
                using (var db = new DbContextHelper())
                {
                    // TODO: Validate the access token

                    var user = ManageUserModelHelper.GetUser(db, idKey: model.IdKey, email: model.Email, screenName: model.ScreenName, facebookId: model.FacebookId);
                    if (user == null)
                    {
                        return(model.Register(out status));
                    }

                    user.AccessToken    = model.AccessToken;
                    user.LastAccessed   = DateTime.Now;
                    user.UserStatusEnum = UserStatus.Online;
                    db.SaveChanges();

                    // Save the user basic information
                    model.Id         = user.Id;
                    model.IdKey      = user.IdKey;
                    model.ScreenName = user.ScreenName;
                    model.FirstName  = user.FirstName;
                    model.LastName   = user.LastName;
                    model.UserStatus = user.UserStatusEnum;
                    model.Roles      = user.Roles.ToList().GetRoleModelsFromRoles();

                    model.CreateAuthorizationTicket();

                    status = Status.Success;
                    return(true);
                }
            }

            catch (Exception ex)
            {
                LogHelper.LogFatalError("FacebookHelper.Authorize", ex);
                status = Status.SystemException;
            }

            return(false);
        }
Esempio n. 11
0
        /// <summary>
        /// Authorize the current user on the site. Authenication occurs via Facebook app
        /// </summary>
        /// <param name="model"></param>
        /// <param name="status"></param>
        /// <returns></returns>
        public static bool Authorize(this UserModel model, out Status status)
        {
            try
            {
                using (var db = new DbContextHelper())
                {
                    var user = ManageUserModelHelper.GetUser(db, model.IdKey, model.Email);
                    if (user == null)
                    {
                        status = Status.InvalidLoginPassword;
                        return(false);
                    }

                    user.AccessToken    = model.AccessToken;
                    user.LastAccessed   = DateTime.Now;
                    user.UserStatusEnum = UserStatus.Online;
                    db.SaveChanges();

                    // Save the user basic information
                    model.Id         = user.Id;
                    model.IdKey      = user.IdKey;
                    model.ScreenName = user.ScreenName;
                    model.FirstName  = user.FirstName;
                    model.LastName   = user.LastName;
                    model.UserStatus = user.UserStatusEnum;
                    model.Roles      = user.Roles.ToList().GetRoleModelsFromRoles();

                    model.CreateAuthorizationTicket();

                    status = Status.Success;
                    return(true);
                }
            }

            catch (Exception ex)
            {
                LogHelper.LogFatalError("UserModelHelper.Authorize", ex);
                status = Status.SystemException;
            }

            return(false);
        }
Esempio n. 12
0
        public static PaginationModel <MinistryModel> GetMinistryModel()
        {
            var model = CommonModelHelper.GetPaginatedModel <MinistryModel>(Constants.Sort_Column_Name, MvcContrib.Sorting.SortDirection.Ascending);

            model.GetPaginatedMinistries();

            var ticket = ManageUserModelHelper.GetFormsAuthenticationTicket();

            if (ticket != null)
            {
                model.UserIdKey = ticket.IdKey();
            }

            model.PageTitle       = "Holy Angels Church Ministries";
            model.MetaDescription = "";
            model.MetaKeywords    = "";
            model.MetaSubject     = "";

            return(model);
        }
Esempio n. 13
0
        public virtual ActionResult Edit(UserModel model)
        {
            if (ModelState.IsValid)
            {
                Status status;
                if (model.Update(out status))
                {
                    ModelState.AddModelError("Error", "User information updated successfully!");
                }
                else
                {
                    ModelState.AddModelError("Error", status.Message());
                }
            }
            else
            {
                ModelState.AddModelError("Error", "Please update the required fields!");
            }

            model = ManageUserModelHelper.GetUserModelForEdit(model.IdKey.ToString());
            return(View(model));
        }
Esempio n. 14
0
        public virtual ActionResult Add()
        {
            var model = ManageUserModelHelper.GetUserModelForAdd();

            return(View(model));
        }
Esempio n. 15
0
        public virtual ActionResult Index(GridSortOptions sort, int page = 1)
        {
            var model = ManageUserModelHelper.GetUserModelForUsers(sort, page);

            return(View(model));
        }