Skip to content

Leeciabarajas/CanvasClone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

seesharp

Test Accounts

Instructor:

instructor@gmai.com; Admin123$

Student:

student@gmail.com; Admin123$

Identity Info:

It appears that Identities also uses sessions, but in a different way than just setting Session variables

Also, it looks like Identities is using a GUID string id for users right now, so all references to InstructorIds and StudentIds use that string Id as a ForeignKey. The ApplicationUser class has a DisplayId which is a simple integer that increments with each user for our Profile "W Number". ApplicationUser also has a description field for the Profile page.

How to Use Identities:

On the cshtml pages, you need to put this line: "@using SeeSharpLMS.Utility" after the "@page" directive to pull in the roles 'InstructorRole' and 'StudentRole'

To block off sections of a cshtml page based on the current user's role, you can do something like the following: "@if(User.IsInRole(SD.InstructorRole)) { }"

To get the current user's information for a page, you need this:

//declared at the class level

private readonly UserManager _userManager; public ApplicationUser user;

//The page constructor uses 'Dependency Injection' by having a paramater of the UserManager

public LandingPageModel(Data.ApplicationDbContext context, UserManager userManager) { _context = context; _userManager = userManager; }

//set in an OnGet or OnPost Method //This goes to the User Table, and will get the user that matches the current user's id so that you can access FirstName, Description, Etc.

user = _context.ApplicationUser.FirstOrDefault(u => u.Id == _userManager.GetUserId(User));

FirstOrDefault can return a null object if nothing matches the comparison criteria, so we should always check for that and display an error to the user if true.

About

Team of 4 used asp.net core to replicate Canvas

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published