From 4b863687d3131856feae49e09dc5accd07d4a700 Mon Sep 17 00:00:00 2001 From: Reginald Cherenfant Jasmin Date: Thu, 21 Dec 2023 16:05:50 -0500 Subject: [PATCH] Adding endpoint to autheticate from mobile --- .../Controllers/UsersAccessController.cs | 21 ++++++++++--------- .../Models/UserCredentials.cs | 2 +- .../appsettings.json | 4 ++-- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/DamageAssesmentApi/DamageAssesment.Api.UsersAccess/Controllers/UsersAccessController.cs b/DamageAssesmentApi/DamageAssesment.Api.UsersAccess/Controllers/UsersAccessController.cs index c17ec40..5e4271c 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.UsersAccess/Controllers/UsersAccessController.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.UsersAccess/Controllers/UsersAccessController.cs @@ -14,16 +14,17 @@ namespace DamageAssesment.Api.UsersAccess.Controllers { this.userAccessProvider = userAccessProvider; } - // [HttpPost("dadeschooltoken")] - // public async Task DadeSchoolAuthenticateAsync(string username, string password) - //{ - // var result = await userAccessProvider.DadeSchoolAuthenticateAsync(username, password); - // if (result.IsSuccess) - // { - // return Ok(result.TokenResponse); - // } - // return Unauthorized(result.ErrorMessage); - // } + [HttpPost("authenticate")] + public async Task DadeSchoolAuthenticateAsync(UserCredentials userCredentials) + { + var result = await userAccessProvider.DadeSchoolAuthenticateAsync(userCredentials.username, userCredentials.password); + if (result.IsSuccess) + { + return Ok(result.TokenResponse); + } + return Unauthorized(result.ErrorMessage); + } + // [Authorize(Policy = "Dadeschools")] [HttpPost("token/{employecode}")] public async Task AuthenticateAsync(string employecode) diff --git a/DamageAssesmentApi/DamageAssesment.Api.UsersAccess/Models/UserCredentials.cs b/DamageAssesmentApi/DamageAssesment.Api.UsersAccess/Models/UserCredentials.cs index cf01fa3..5e764fb 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.UsersAccess/Models/UserCredentials.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.UsersAccess/Models/UserCredentials.cs @@ -1,5 +1,5 @@ public class UserCredentials { public string username { get; set; } - // public string? password { get; set; } + public string password { get; set; } } \ No newline at end of file diff --git a/DamageAssesmentApi/DamageAssesment.Api.UsersAccess/appsettings.json b/DamageAssesmentApi/DamageAssesment.Api.UsersAccess/appsettings.json index ca3c7b8..7719f01 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.UsersAccess/appsettings.json +++ b/DamageAssesmentApi/DamageAssesment.Api.UsersAccess/appsettings.json @@ -20,8 +20,8 @@ }, "AllowedHosts": "*", "Dadeschools": { - "Authority": "https://dev-graph.dadeschools.net", - "TokenUrl": "https://dev-graph.dadeschools.net/connect/token", + "Authority": "https://graph2.dadeschools.net", + "TokenUrl": "https://graph2.dadeschools.net/connect/token", "ClientId": "dmapi", "ClientSecret": "bfce2c8d-2064-4a02-b19d-7f1d42b16eae", "TokenClientId": "damage_assessment_postman",