예제 #1
0
        /// <summary>
        /// Returns the logged in user
        /// </summary>
        /// <returns></returns>
        public static IdentityUser GetCurrentUser()
        {
            string user_id = null;
            var claimsIdentity = System.Web.HttpContext.Current.GetOwinContext().Authentication.User.Identity as ClaimsIdentity;
            if (claimsIdentity != null)
            {
                var userIdClaim = claimsIdentity.Claims
               .FirstOrDefault(x => x.Type == ClaimTypes.NameIdentifier);

                if (userIdClaim != null)
                {
                    user_id = userIdClaim.Value;
                }
            }
            if (user_id != null)
            {
                MySQLDatabase db = new MySQLDatabase("DefaultConnection");
                UserTable<IdentityUser> table = new UserTable<IdentityUser>(db);
                var user = table.GetUserById(user_id);
                return user;
            }
            return null;
        }
예제 #2
0
 /// <summary>
 /// Constructor that takes a MySQLDatabase instance 
 /// </summary>
 /// <param name="database"></param>
 public RoleTable(MySQLDatabase database)
 {
     _database = database;
 }
예제 #3
0
 /// <summary>
 /// Constructor that takes a MySQLDatabase instance 
 /// </summary>
 /// <param name="database"></param>
 public UserClaimsTable(MySQLDatabase database)
 {
     _database = database;
 }