Skip to content

Commit

Permalink
Remove unnecessary code related to authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
yorickdewid committed Dec 18, 2023
1 parent 5e38dff commit dc7f101
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
6 changes: 0 additions & 6 deletions src/FunderMaps.Webservice/Controllers/AuthController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
using FunderMaps.Core.Controllers;
using FunderMaps.Core.DataTransferObjects;
using FunderMaps.Core.Services;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

Expand All @@ -27,8 +25,6 @@ public async Task<SignInSecurityTokenDto> SignInAsync([FromBody] SignInDto input
{
var principal = await signInService.PasswordSignInAsync(input.Email, input.Password, "FunderMapsHybridAuth");

await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, principal);

var tokenContext = tokenService.GetTokenContext(principal);
return new SignInSecurityTokenDto()
{
Expand All @@ -51,8 +47,6 @@ public async Task<SignInSecurityTokenDto> RefreshSignInAsync()
{
var principal = await signInService.UserIdSignInAsync(UserId, "FunderMapsHybridAuth");

await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, principal);

var tokenContext = tokenService.GetTokenContext(principal);
return new SignInSecurityTokenDto()
{
Expand Down
15 changes: 4 additions & 11 deletions tests/FunderMaps.Webservice.Tests/Controllers/AuthTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public async Task SignInReturnSuccessAndToken(string email)
{
using var client = factory.CreateClient();

var response = await client.PostAsJsonAsync("api/auth/signin", new SignInDto()
var response = await client.PostAsJsonAsync("api/auth/signin", new SignInDto
{
Email = email,
Password = "fundermaps",
Expand All @@ -44,7 +44,7 @@ public async Task RefreshSignInReturnSuccessAndToken()
{
using var client = factory.CreateClient();

var authResponse = await client.PostAsJsonAsync("api/auth/signin", new SignInDto()
var authResponse = await client.PostAsJsonAsync("api/auth/signin", new SignInDto
{
Email = "lester@contoso.com",
Password = "fundermaps",
Expand Down Expand Up @@ -96,14 +96,8 @@ public async Task SignInInvalidCredentialsReturnError()
Email = "lester@contoso.com",
Password = new Randomizer().Password(64),
});
// var returnObject = await response.Content.ReadFromJsonAsync<ProblemModel>();

Assert.NotEqual(HttpStatusCode.OK, response.StatusCode);

// Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode);
// Assert.NotNull(returnObject);
// Assert.Equal((short)HttpStatusCode.Unauthorized, returnObject.Status);
// Assert.Contains("Login", returnObject.Title, StringComparison.InvariantCultureIgnoreCase);
Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode);
}

[Theory]
Expand All @@ -130,7 +124,6 @@ public async Task RefreshSignInReturnUnauthorized()

var response = await client.GetAsync("api/auth/token-refresh");

// Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode);
Assert.NotEqual(HttpStatusCode.OK, response.StatusCode);
Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode);
}
}

0 comments on commit dc7f101

Please sign in to comment.