Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. public class DefaultController : Controller
  2. {
  3. protected readonly DatabaseContext _context;
  4. protected readonly User _user;
  5.  
  6. public DefaultController(DatabaseContext context)
  7. {
  8. _context = context;
  9.  
  10. if (HttpContext.Request.RequiresAuthorization) // pseudo code
  11. {
  12. var id = User.FindFirst(ClaimTypes.NameIdentifier).Value;
  13. _user = _context.Users.Find(id);
  14. }
  15. }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement