Skip to content

Commit 757ee2d

Browse files
committed
Removed old LocalizeResources + fix some old status
1 parent 57929f3 commit 757ee2d

File tree

15 files changed

+51
-64
lines changed

15 files changed

+51
-64
lines changed

AuthPermissions.AspNetCore/AccessTenantData/Services/LinkToTenantDataService.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) 2022 Jon P Smith, GitHub: JonPSmith, web: http://www.thereformedprogrammer.net/
22
// Licensed under MIT license. See License.txt in the project root for license information.
33

4-
using System.Threading.Tasks;
54
using AuthPermissions.AdminCode;
65
using AuthPermissions.BaseCode;
76
using AuthPermissions.BaseCode.CommonCode;
@@ -59,15 +58,16 @@ public LinkToTenantDataService(
5958
/// <exception cref="AuthPermissionsException"></exception>
6059
public async Task<IStatusGeneric> StartLinkingToTenantDataAsync(string currentUserId, int tenantId)
6160
{
62-
var status = new StatusGenericLocalizer<ResourceLocalize>(_localizeDefault);
61+
var status = new StatusGenericLocalizer(_localizeDefault);
6362

6463
if (_options.LinkToTenantType == LinkToTenantTypes.NotTurnedOn)
6564
throw new AuthPermissionsException(
6665
$"You must set up the {nameof(AuthPermissionsOptions.LinkToTenantType)} to use the Access Tenant Data feature.");
6766

6867
var user = await _context.AuthUsers.SingleOrDefaultAsync(x => x.UserId == currentUserId);
6968
if (user == null)
70-
return status.AddErrorString("UserNotFound".ClassLocalizeKey(this, true), "Could not find the user you were looking for.");
69+
return status.AddErrorString("UserNotFound".ClassLocalizeKey(this, true), //common
70+
"Could not find the user you were looking for.");
7171

7272
if (user.TenantId != null && _options.LinkToTenantType != LinkToTenantTypes.AppAndHierarchicalUsers)
7373
throw new AuthPermissionsException(
@@ -76,7 +76,8 @@ public async Task<IStatusGeneric> StartLinkingToTenantDataAsync(string currentUs
7676

7777
var tenantToLinkTo = await _context.Tenants.SingleOrDefaultAsync(x => x.TenantId == tenantId);
7878
if (tenantToLinkTo == null)
79-
return status.AddErrorString("TenantNotFound".ClassLocalizeKey(this, true), "Could not find the tenant you were looking for.");
79+
return status.AddErrorString("TenantNotFound".ClassLocalizeKey(this, true),
80+
"Could not find the tenant you were looking for.");
8081

8182
if (status.HasErrors)
8283
return status;

AuthPermissions.AspNetCore/JwtTokenCode/TokenBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public async Task<TokenAndRefreshToken> GenerateTokenAndRefreshTokenAsync(string
7676

7777
var refreshToken = RefreshToken.CreateNewRefreshToken(userId, token.Id);
7878
_context.Add(refreshToken);
79-
var status = await _context.SaveChangesWithChecksAsync(new StubDefaultLocalizer<ResourceLocalize>());
79+
var status = await _context.SaveChangesWithChecksAsync(new StubDefaultLocalizer());
8080
status.IfErrorsTurnToException();
8181

8282
return new TokenAndRefreshToken
@@ -146,7 +146,7 @@ public async Task<TokenAndRefreshToken> GenerateTokenAndRefreshTokenAsync(string
146146
var newRefreshToken = RefreshToken.CreateNewRefreshToken(userId, token.Id);
147147

148148
_context.Add(newRefreshToken);
149-
var status = await _context.SaveChangesWithChecksAsync(new StubDefaultLocalizer<ResourceLocalize>());
149+
var status = await _context.SaveChangesWithChecksAsync(new StubDefaultLocalizer());
150150
status.IfErrorsTurnToException();
151151

152152
return (new TokenAndRefreshToken

AuthPermissions.AspNetCore/Services/DisableJwtRefreshToken.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public async Task LogoutUserViaRefreshTokenAsync(string refreshToken)
4343
if (latestValidRefreshToken != null)
4444
{
4545
latestValidRefreshToken.MarkAsInvalid();
46-
var status = await _context.SaveChangesWithChecksAsync(new StubDefaultLocalizer<ResourceLocalize>());
46+
var status = await _context.SaveChangesWithChecksAsync(new StubDefaultLocalizer());
4747
status.IfErrorsTurnToException();
4848
}
4949
}
@@ -61,7 +61,7 @@ public async Task LogoutUserViaUserIdAsync(string userId)
6161
.ToListAsync();
6262

6363
latestValidRefreshTokens.ForEach(x => x.MarkAsInvalid());
64-
var status = await _context.SaveChangesWithChecksAsync(new StubDefaultLocalizer<ResourceLocalize>());
64+
var status = await _context.SaveChangesWithChecksAsync(new StubDefaultLocalizer());
6565
status.IfErrorsTurnToException();
6666
}
6767
}

AuthPermissions.AspNetCore/Services/ShardingConnections.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public string FormConnectionString(string databaseInfoName)
156156
/// <exception cref="ArgumentNullException"></exception>
157157
public IStatusGeneric TestFormingConnectionString(DatabaseInformation databaseInfo)
158158
{
159-
var status = new StatusGenericLocalizer<ResourceLocalize>(_localizeDefault);
159+
var status = new StatusGenericLocalizer(_localizeDefault);
160160

161161
if (databaseInfo == null)
162162
throw new ArgumentNullException(nameof(databaseInfo));

AuthPermissions.BaseCode/DataLayer/EfCode/SaveChangesExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ private enum ExceptionTypes {Duplicate, ConcurrencyError}
7474
private static IStatusGeneric ConvertExceptionToStatus(this IReadOnlyList<EntityEntry> entities,
7575
ExceptionTypes exceptionType, IDefaultLocalizer localizeDefault)
7676
{
77-
var status = new StatusGenericLocalizer<ResourceLocalize>(localizeDefault);
77+
var status = new StatusGenericLocalizer(localizeDefault);
7878

7979
//NOTE: These is only one entity in an exception
8080
if (entities.Any())

AuthPermissions.BaseCode/LocalizeResources.cs

Lines changed: 0 additions & 16 deletions
This file was deleted.

AuthPermissions.SupportCode/AddUsersServices/Authentication/AzureAdNewUserManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public AzureAdNewUserManager(IAuthUsersAdminService authUsersAdmin, IAuthTenantA
6363
/// <returns>status, with error if there an user already</returns>
6464
public async Task<IStatusGeneric> CheckNoExistingAuthUserAsync(AddNewUserDto newUser)
6565
{
66-
var status = new StatusGenericLocalizer<ResourceLocalize>(_localizeDefault);
66+
var status = new StatusGenericLocalizer(_localizeDefault);
6767
if ((await _authUsersAdmin.FindAuthUserByEmailAsync(newUser.Email))?.Result != null)
6868
return status.AddErrorString("ExistingUser".ClassLocalizeKey(this, true),
6969
"There is already an AuthUser with your email, so you can't add another.",

AuthPermissions.SupportCode/AddUsersServices/Authentication/IndividualUserAddUserManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public IndividualUserAddUserManager(IAuthUsersAdminService authUsersAdmin, IAuth
6363
/// <returns>status, with error if there an user already</returns>
6464
public async Task<IStatusGeneric> CheckNoExistingAuthUserAsync(AddNewUserDto newUser)
6565
{
66-
var status = new StatusGenericLocalizer<ResourceLocalize>(_localizeDefault);
66+
var status = new StatusGenericLocalizer(_localizeDefault);
6767
if ((await _authUsersAdmin.FindAuthUserByEmailAsync(newUser.Email))?.Result != null)
6868
return status.AddErrorString("ExistingUser".ClassLocalizeKey(this, true),
6969
"There is already an AuthUser with your email, so you can't add another.",
@@ -83,7 +83,7 @@ public async Task<IStatusGeneric> SetUserInfoAsync(AddNewUserDto newUser)
8383
{
8484
UserLoginData = newUser ?? throw new ArgumentNullException(nameof(newUser));
8585

86-
var status = new StatusGenericLocalizer<ResourceLocalize>(_localizeDefault);
86+
var status = new StatusGenericLocalizer(_localizeDefault);
8787
status.SetMessageString("SuccessAddUser".ClassLocalizeKey(this, true),
8888
"New user with claims added");
8989

AuthPermissions.SupportCode/ShardingServices/AccessDatabaseInformation.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public IStatusGeneric UpdateDatabaseInfoToJsonFile(DatabaseInformation databaseI
106106
{
107107
return ApplyChangeWithinDistributedLock(() =>
108108
{
109-
var status = new StatusGenericLocalizer<ResourceLocalize>(_localizeDefault);
109+
var status = new StatusGenericLocalizer(_localizeDefault);
110110
var fileContent = ReadShardingSettingsFile();
111111
var foundIndex = fileContent.FindIndex(x => x.Name == databaseInfo.Name);
112112
if (foundIndex == -1)
@@ -128,7 +128,7 @@ public async Task<IStatusGeneric> RemoveDatabaseInfoToJsonFileAsync(string datab
128128
{
129129
return await ApplyChangeWithinDistributedLockAsync(async () =>
130130
{
131-
var status = new StatusGenericLocalizer<ResourceLocalize>(_localizeDefault);
131+
var status = new StatusGenericLocalizer(_localizeDefault);
132132
var fileContent = ReadShardingSettingsFile();
133133
var foundIndex = fileContent.FindIndex(x => x.Name == databaseInfoName);
134134
if (foundIndex == -1)
@@ -152,7 +152,7 @@ public async Task<IStatusGeneric> RemoveDatabaseInfoToJsonFileAsync(string datab
152152

153153
private IStatusGeneric CheckDatabasesInfoAndSaveIfValid(List<DatabaseInformation> databasesInfo, DatabaseInformation changedInfo)
154154
{
155-
var status = new StatusGenericLocalizer<ResourceLocalize>(_localizeDefault);
155+
var status = new StatusGenericLocalizer(_localizeDefault);
156156
status.SetMessageFormatted("SuccessUpdate".ClassLocalizeKey(this, true),
157157
$"Successfully updated the {ShardingSettingFilename} with your changes.");
158158

AuthPermissions/AdminCode/Services/AuthRolesAdminService.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public async Task<IStatusGeneric> CreateRoleToPermissionsAsync(string roleName,
111111
IEnumerable<string> permissionNames,
112112
string description, RoleTypes roleType = RoleTypes.Normal)
113113
{
114-
var status = new StatusGenericLocalizer<ResourceLocalize>(_localizeDefault);
114+
var status = new StatusGenericLocalizer(_localizeDefault);
115115
status.SetMessageFormatted("Success".ClassMethodLocalizeKey(this, true),
116116
$"Successfully added the new role {roleName}.");
117117

@@ -156,7 +156,7 @@ public async Task<IStatusGeneric> UpdateRoleToPermissionsAsync(string roleName,
156156
IEnumerable<string> permissionNames,
157157
string description, RoleTypes roleType = RoleTypes.Normal)
158158
{
159-
var status = new StatusGenericLocalizer<ResourceLocalize>(_localizeDefault);
159+
var status = new StatusGenericLocalizer(_localizeDefault);
160160
status.SetMessageFormatted("Success".ClassMethodLocalizeKey(this, true),
161161
$"Successfully updated the role {roleName}.");
162162
var existingRolePermission = await _context.RoleToPermissions.SingleOrDefaultAsync(x => x.RoleName == roleName);
@@ -186,7 +186,7 @@ public async Task<IStatusGeneric> UpdateRoleToPermissionsAsync(string roleName,
186186
//We need to check that the new RoleType matches where they are used
187187
var roleChecker = new ChangeRoleTypeChecks(_context);
188188
if (status.CombineStatuses(
189-
await roleChecker.CheckRoleTypeChangeAsync(originalRoleType, roleType,roleName)).HasErrors)
189+
await roleChecker.CheckRoleTypeChangeAsync(originalRoleType, roleType,roleName, _localizeDefault)).HasErrors)
190190
return status;
191191
}
192192

@@ -206,7 +206,7 @@ await roleChecker.CheckRoleTypeChangeAsync(originalRoleType, roleType,roleName))
206206
/// <returns>status</returns>
207207
public async Task<IStatusGeneric> DeleteRoleAsync(string roleName, bool removeFromUsers)
208208
{
209-
var status = new StatusGenericLocalizer<ResourceLocalize>(_localizeDefault);
209+
var status = new StatusGenericLocalizer(_localizeDefault);
210210

211211
var existingRolePermission =
212212
await _context.RoleToPermissions.SingleOrDefaultAsync(x => x.RoleName == roleName);

0 commit comments

Comments
 (0)