Fixed a bunch of warnings
This commit is contained in:
@@ -2,7 +2,6 @@ using FoodsharingSiegen.Contracts;
|
||||
using FoodsharingSiegen.Contracts.Entity;
|
||||
using FoodsharingSiegen.Contracts.Helper;
|
||||
using FoodsharingSiegen.Server.Data;
|
||||
using FoodsharingSiegen.Server.Data.Service;
|
||||
using FoodsharingSiegen.Server.Service;
|
||||
using FoodsharingSiegen.Shared.Helper;
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
@@ -100,7 +99,7 @@ namespace FoodsharingSiegen.Server.Auth
|
||||
{
|
||||
#region Ensure Admin
|
||||
|
||||
var existingTroogS = await Context.Users.AnyAsync(x => x.Mail == "fs@beging.de");
|
||||
var existingTroogS = await Context.Users!.AnyAsync(x => x.Mail == "fs@beging.de");
|
||||
if (!existingTroogS)
|
||||
{
|
||||
var troogs = new User
|
||||
@@ -113,7 +112,7 @@ namespace FoodsharingSiegen.Server.Auth
|
||||
EncryptedPassword = "qSIxTZo7J8M="
|
||||
};
|
||||
|
||||
await Context.Users.AddAsync(troogs);
|
||||
await Context.Users!.AddAsync(troogs);
|
||||
await Context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
@@ -121,7 +120,7 @@ namespace FoodsharingSiegen.Server.Auth
|
||||
|
||||
var encryptedPassword = Cryptor.Encrypt(password);
|
||||
|
||||
_user = await Context.Users.FirstOrDefaultAsync(x => x.Mail.ToLower() == mailAddress.ToLower() && x.EncryptedPassword == encryptedPassword);
|
||||
_user = await Context.Users!.FirstOrDefaultAsync(x => x.Mail.ToLower() == mailAddress.ToLower() && x.EncryptedPassword == encryptedPassword);
|
||||
|
||||
if (_user != null)
|
||||
{
|
||||
|
||||
@@ -2,12 +2,12 @@ using System.Security.Claims;
|
||||
using FoodsharingSiegen.Contracts;
|
||||
using FoodsharingSiegen.Contracts.Entity;
|
||||
using FoodsharingSiegen.Server.Data;
|
||||
using FoodsharingSiegen.Server.Data.Service;
|
||||
using FoodsharingSiegen.Server.Service;
|
||||
using FoodsharingSiegen.Shared.Helper;
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace FoodsharingSiegen.Server.Service
|
||||
namespace FoodsharingSiegen.Server.Auth
|
||||
{
|
||||
/// <summary>
|
||||
/// The token auth state provider class (a. beging, 02.04.2022)
|
||||
@@ -84,11 +84,13 @@ namespace FoodsharingSiegen.Server.Service
|
||||
/// </summary>
|
||||
/// <param name="user">The user</param>
|
||||
/// <returns>A task containing an operation result of bool</returns>
|
||||
public async Task<OperationResult<bool>> CheckForceLogout(User user)
|
||||
public async Task<OperationResult<bool>> CheckForceLogout(User? user)
|
||||
{
|
||||
try
|
||||
{
|
||||
var anyR = await Context.Users.AnyAsync(x => x.Id == user.Id && x.ForceLogout);
|
||||
if (user == null) return new OperationResult<bool>(new Exception());
|
||||
|
||||
var anyR = await Context.Users!.AnyAsync(x => x.Id == user.Id && x.ForceLogout);
|
||||
return new OperationResult<bool>(anyR);
|
||||
}
|
||||
catch (Exception e)
|
||||
|
||||
Reference in New Issue
Block a user