Changeset bf18ca4 for iknow-api


Ignore:
Timestamp:
12/21/25 18:15:59 (9 months ago)
Author:
Stefan-Saveski <stefansaveski19@…>
Branches:
master
Children:
97a2322
Parents:
2e17229
Message:

Added dockerfile and changes to GET user.

Location:
iknow-api
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • iknow-api/Controllers/UserController.cs

    r2e17229 rbf18ca4  
    1515            _userService = userService;
    1616        }
     17
     18        //  "birthInfo": {
     19        //    "placeOfBirth": "Скопје",
     20        //    "municipalityOfBirth": "Скопје",
     21        //    "country": "Република Северна Македонија"
     22        //  },
     23        //  "previousEducation": {
     24        //    "type": "Гимназиско образование",
     25        //    "profession": "",
     26        //    "average": "54,857",
     27        //    "language": "Македонски",
     28        //    "country": "",
     29        //    "previousUniversity": "Гимназиско образование",
     30        //    "previousFaculty": "",
     31        //    "previousStudyMode": ""
     32        //  },
     33        //  "enrollmentInfo": {
     34        //    "enrollmentYear": "2023",
     35        //    "status": "Редовен",
     36        //    "cycle": "Прв циклус",
     37        //    "program": "Примена на информациски технологии",
     38        //    "quota": "Кофинансирање-Редовен (2023, 24600)",
     39        //    "secondaryEducationNumber": "",
     40        //    "previousEducationCredits": ""
     41        //  },
     42        //  "contact": {
     43        //    "placeOfResidence": "Скопје",
     44        //    "municipalityOfResidence": "Кисела Вода - Скопје",
     45        //    "country": "Република Северна Македонија",
     46        //    "address": "Драчево",
     47        //    "temporaryAddress": "",
     48        //    "phone": "",
     49        //    "mobilePhone": "075295582",
     50        //    "passportNumber": "",
     51        //    "passportExpiryDate": "",
     52        //    "email": "stefansaveski19@gmail.com",
     53        //    "microsoftEmail": "stefan.saveski@students.finki.ukim.mk"
     54        //  }
     55        //}
    1756        [Authorize]
    1857        [HttpGet("getUser")]
    1958        public async Task<IActionResult> getUser()
    2059        {
     60            //{
     61            //  "personalInfo": {
     62            //    "index": "233149/2023",
     63            //    "embg": "/////////////",
     64            //    "lastName": "Савески",
     65            //    "middleName": "Дејан",
     66            //    "firstName": "Стефан",
     67            //    "maidenName": "",
     68            //    "dateOfBirth": "19.08.2004",
     69            //    "gender": "машки",
     70            //    "nationality": "Македонец",
     71            //    "citizenship": "Република Северна Македонија",
     72            //    "scholarship": "Користи",
     73            //    "currentPlan": "2023",
     74            //    "registryNumber": "",
     75            //    "notes": "Систематски преглед Студира 3 години",
     76            //    "studyGroup": ""
     77            //  },
    2178            var authHeader = Request.Headers["Authorization"].ToString();
    2279            if (authHeader.StartsWith("Bearer "))
     
    2683                var userData = await _userService.GetUserData(token);
    2784                if (userData == null) return Ok(new { info = "can't get info" });
    28                 return Ok(new { User = userData });
     85                var personalInfo = new
     86                {
     87                    index = userData.Index ?? "",
     88                    embg = userData.EMBG ?? "",
     89                    lastName = userData.Surname ?? "",
     90                    middleName = userData.MiddleName ?? "",
     91                    firstName = userData.Name ?? "",
     92                    maidenName = "", // Property doesn't exist in User model
     93                    dateOfBirth = userData.Bday.ToString("dd.MM.yyyy"),
     94                    gender = userData.Gender ?? "",
     95                    nationality = userData.Nationality ?? "",
     96                    citizenship = userData.Citizenship ?? "",
     97                    scholarship = "",
     98                    currentPlan = userData.EnrollmentInfo?.EnrollmentYear.ToString() ?? "",
     99                    registryNumber = "",
     100                    notes = "",
     101                    studyGroup = ""
     102                };
     103                var birthInfo = new
     104                {
     105                    placeOfBirth = userData.ContactInfo?.City ?? "",
     106                    municipalityOfBirth = userData.ContactInfo?.Municipality ?? "",
     107                    country = userData.Citizenship ?? ""
     108                };
     109                var previousEducation = new
     110                {
     111                    type = userData.HighSchool?.HighSchoolType.ToString() ?? "",
     112                    profession = "",
     113                    average = userData.HighSchool?.GPA.ToString() ?? "",
     114                    language = userData.Nationality ?? "",
     115                    country = userData.Nationality ?? "",
     116                    previousUniversity = userData.HighSchool?.HighSchoolType.ToString() ?? "",
     117                    previousFaculty = "", // Property doesn't exist in HighSchool model
     118                    previousStudyMode = "" // Property doesn't exist in HighSchool model
     119                };
     120                var enrollmentInfo = new
     121                {
     122                    enrollmentYear = userData.EnrollmentInfo?.EnrollmentYear.ToString() ?? "",
     123                    status = userData.EnrollmentInfo?.StudyStatus ?? "",
     124                    cycle = "Прв циклус",
     125                    program = userData.EnrollmentInfo?.Major?.Name ?? "",
     126                    quota = userData.EnrollmentInfo?.Quota.ToString() ?? "",
     127                    secondaryEducationNumber = "",
     128                    previousEducationCredits = ""
     129                };
     130                var contact = new
     131                {
     132                    placeOfResidence = userData.ContactInfo?.City ?? "",
     133                    municipalityOfResidence = userData.ContactInfo?.Municipality ?? "",
     134                    country = userData.Citizenship ?? "",
     135                    address = userData.ContactInfo?.Address ?? "",
     136                    temporaryAddress = "",
     137                    phone = "",
     138                    mobilePhone = userData.ContactInfo?.PhoneNumber ?? "",
     139                    passportNumber = "",
     140                    passportExpiryDate = "",
     141                    email = userData.Email ?? "",
     142                    microsoftEmail = userData.ContactInfo?.MicrosoftEmail ?? ""
     143                };
     144                return Ok(new { personalInfo = personalInfo, birthInfo = birthInfo, previousEducation = previousEducation, enrollmentInfo = enrollmentInfo, contact = contact });
     145                //return Ok(new { User = userData });
    29146            }
    30147            return null;
  • iknow-api/Program.cs

    r2e17229 rbf18ca4  
    99
    1010var builder = WebApplication.CreateBuilder(args);
     11
     12// Add CORS policy
     13builder.Services.AddCors(options =>
     14{
     15    options.AddPolicy("AllowFrontend", policy =>
     16    {
     17        var allowedOrigins = builder.Configuration.GetSection("AllowedOrigins").Get<string[]>()
     18            ?? new[] { "http://localhost:3000" };
     19       
     20        policy.WithOrigins(allowedOrigins) // Your frontend URL(s)
     21              .AllowAnyHeader()
     22              .AllowAnyMethod()
     23              .AllowCredentials();
     24    });
     25});
     26
    1127builder.Services.AddAuthentication(options =>
    1228{
     
    6480}
    6581
     82// Enable CORS - must be called before UseAuthentication and UseAuthorization
     83app.UseCors("AllowFrontend");
     84
    6685app.UseHttpsRedirection();
    6786app.UseAuthentication(); // <-- must come BEFORE UseAuthorization
  • iknow-api/appsettings.json

    r2e17229 rbf18ca4  
    66    }
    77  },
     8  "AllowedOrigins": [
     9    "http://localhost:3000"
     10  ],
    811  "ConnectionStrings": {
    912    "DefaultConnection": "Host=ep-divine-term-aghfotgc-pooler.c-2.eu-central-1.aws.neon.tech; Database=neondb; Username=neondb_owner; Password=REDACTED_ROTATE_ME; SSL Mode=VerifyFull; Channel Binding=Require;"
Note: See TracChangeset for help on using the changeset viewer.