/// <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; }
/// <summary> /// Constructor that takes a MySQLDatabase instance /// </summary> /// <param name="database"></param> public RoleTable(MySQLDatabase database) { _database = database; }
/// <summary> /// Constructor that takes a MySQLDatabase instance /// </summary> /// <param name="database"></param> public UserClaimsTable(MySQLDatabase database) { _database = database; }