Exemplo n.º 1
0
 string IWebSecurityService.GetUserName(int userId)
 {
     string userName;
      // Insert a new user into the database
     using (UsersContext db = new UsersContext())
     {
         UserProfile user = db.UserProfiles.FirstOrDefault(u => u.UserId == userId);
         userName = user.UserName;
     }
     return userName;
 }
Exemplo n.º 2
0
 string IWebSecurityService.GeneratePasswordResetToken(int userId, int tokenExpirationInMinutesFromNow)
 {
     string userName;
     // Insert a new user into the database
     using (UsersContext db = new UsersContext())
     {
         UserProfile user = db.UserProfiles.FirstOrDefault(u => u.UserId == userId);
         userName = user.UserName;
     }
     return WebSecurity.GeneratePasswordResetToken(userName, tokenExpirationInMinutesFromNow);
 }
Exemplo n.º 3
0
        public static void RegisterUserDB()
        {
            Database.SetInitializer<UsersContext>(null);

            try
            {
                using (var context = new UsersContext())
                {
                    if (!context.Database.Exists())
                    {
                        // Create the SimpleMembership database without Entity Framework migration schema
                        ((IObjectContextAdapter)context).ObjectContext.CreateDatabase();
                    }
                }

                WebSecurity.InitializeDatabaseConnection("WeNeedUHaveContext", "UserProfile", "UserId", "UserName", autoCreateTables: true);
            }
            catch (Exception ex)
            {
                throw new InvalidOperationException("The ASP.NET Simple Membership database could not be initialized. For more information, please see http://go.microsoft.com/fwlink/?LinkId=256588", ex);
            }
        }