|
Last change
on this file since cab02ad was cab02ad, checked in by stefansaveski <stefansaveski19@…>, 11 months ago |
|
Add user-related models, services, and JWT validation
Added ContactInfo, EnrollmentInfo, and HighSchool models with relationships to the User entity. Updated AppDbContext and migrations to reflect these changes. Introduced UserService and IUserService for handling user data retrieval via JWT validation. Added UserController with a getUser endpoint to fetch user data based on JWT.
Enhanced IUserRepository and UserRepository with a method to fetch users by ID. Registered UserService in the DI container. Defined enums for EnrollmentInfo and HighSchool. Removed outdated migration files and performed general refactoring and cleanup.
|
-
Property mode
set to
100644
|
|
File size:
1.3 KB
|
| Line | |
|---|
| 1 | namespace iknow_api.DTOs
|
|---|
| 2 | {
|
|---|
| 3 | // Login DTO
|
|---|
| 4 | public class LoginDto
|
|---|
| 5 | {
|
|---|
| 6 | public string Email { get; set; } = string.Empty;
|
|---|
| 7 | public string Password { get; set; } = string.Empty;
|
|---|
| 8 | }
|
|---|
| 9 | public class GetUserDataDto
|
|---|
| 10 | {
|
|---|
| 11 | public string JWT { get; set; }
|
|---|
| 12 | }
|
|---|
| 13 |
|
|---|
| 14 | // Registration DTO
|
|---|
| 15 | public class RegisterDto
|
|---|
| 16 | {
|
|---|
| 17 | public string Name { get; set; } = string.Empty;
|
|---|
| 18 | public string Surname { get; set; } = string.Empty;
|
|---|
| 19 | public string? Index { get; set; }
|
|---|
| 20 | public string Email { get; set; } = string.Empty;
|
|---|
| 21 | public string Password { get; set; } = string.Empty;
|
|---|
| 22 | public DateTime Bday { get; set; }
|
|---|
| 23 | public UserRole Role { get; set; }
|
|---|
| 24 | }
|
|---|
| 25 |
|
|---|
| 26 | // User response DTO (for returning user data without password)
|
|---|
| 27 | public class UserResponseDto
|
|---|
| 28 | {
|
|---|
| 29 | public int Id { get; set; }
|
|---|
| 30 | public string? Name { get; set; }
|
|---|
| 31 | public string? Surname { get; set; }
|
|---|
| 32 | public string? Index { get; set; }
|
|---|
| 33 | public string? Email { get; set; }
|
|---|
| 34 | public DateTime Bday { get; set; }
|
|---|
| 35 | public DateTime CreatedAt { get; set; }
|
|---|
| 36 | public UserRole Role { get; set; }
|
|---|
| 37 | }
|
|---|
| 38 |
|
|---|
| 39 | // User role enum
|
|---|
| 40 | public enum UserRole
|
|---|
| 41 | {
|
|---|
| 42 | Admin,
|
|---|
| 43 | Professor,
|
|---|
| 44 | Student
|
|---|
| 45 | }
|
|---|
| 46 | } |
|---|
Note:
See
TracBrowser
for help on using the repository browser.