Skip to content

Commit 61480df

Browse files
authored
Merge pull request #409 from Ketteiteki/remove_logout_all_devices_and_fix_binding_in_settings_page
remove logout all devices | fix binding in settings page
2 parents 9bc7b69 + 9d71911 commit 61480df

9 files changed

Lines changed: 42 additions & 141 deletions

File tree

MangoAPI.BusinessLogic/ApiCommands/Sessions/LogoutAllCommand.cs

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

MangoAPI.BusinessLogic/ApiCommands/Sessions/LogoutAllCommandHandler.cs

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

MangoAPI.BusinessLogic/MangoAPI.BusinessLogic.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<ProjectReference Include="..\MangoAPI.Application\MangoAPI.Application.csproj"/>
13-
<ProjectReference Include="..\MangoAPI.Infrastructure\MangoAPI.Infrastructure.csproj"/>
14-
<ProjectReference Include="..\MangoAPI.Domain\MangoAPI.Domain.csproj"/>
12+
<ProjectReference Include="..\MangoAPI.Application\MangoAPI.Application.csproj" />
13+
<ProjectReference Include="..\MangoAPI.Infrastructure\MangoAPI.Infrastructure.csproj" />
14+
<ProjectReference Include="..\MangoAPI.Domain\MangoAPI.Domain.csproj" />
1515
</ItemGroup>
1616
</Project>

MangoAPI.Client/src/app/components/settings/settings.component.html

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ <h5>Profile</h5>
3232
<button class="button-dark py-2 contact-button px-4" (click)="onLogoutClick()">
3333
Logout
3434
</button>
35-
<button class="button-dark py-2 contact-button px-4 ml-3" (click)="onLogoutAllClick()">
36-
Logout All Devices
37-
</button>
3835
</div>
3936
</div>
4037
<ul class="user-info">
@@ -135,7 +132,7 @@ <h5 class="mb-2">Account</h5>
135132
value="{{ currentUser.birthdayDate }}"
136133
id="BirthdayDate"
137134
placeholder="Type your birthday"
138-
[(ngModel)]="currentUser.birthdayDate"
135+
[(ngModel)]="currentUserForUpdating.birthdayDate"
139136
/>
140137
</li>
141138

@@ -146,7 +143,7 @@ <h5 class="mb-2">Account</h5>
146143
type="text"
147144
id="Website"
148145
placeholder="Type your website"
149-
[(ngModel)]="currentUser.website"
146+
[(ngModel)]="currentUserForUpdating.website"
150147
/>
151148
</li>
152149
</ul>
@@ -158,7 +155,7 @@ <h5 class="mb-2">Account</h5>
158155
type="text"
159156
id="UserName"
160157
placeholder="Type your user name"
161-
[(ngModel)]="currentUser.username"
158+
[(ngModel)]="currentUserForUpdating.username"
162159
/>
163160
</li>
164161

@@ -169,7 +166,7 @@ <h5 class="mb-2">Account</h5>
169166
type="text"
170167
id="DisplayName"
171168
placeholder="Type your display name"
172-
[(ngModel)]="currentUser.displayName"
169+
[(ngModel)]="currentUserForUpdating.displayName"
173170
/>
174171
</li>
175172
</ul>
@@ -180,7 +177,7 @@ <h5 class="mb-2">Account</h5>
180177
type="text"
181178
id="Bio"
182179
placeholder="Type your bio"
183-
[(ngModel)]="currentUser.bio"
180+
[(ngModel)]="currentUserForUpdating.bio"
184181
/>
185182
</div>
186183
<div class="d-flex flex-column profile-form-group">
@@ -190,7 +187,7 @@ <h5 class="mb-2">Account</h5>
190187
type="text"
191188
id="Address"
192189
placeholder="Type your address"
193-
[(ngModel)]="currentUser.address"
190+
[(ngModel)]="currentUserForUpdating.address"
194191
/>
195192
</div>
196193
</div>
@@ -215,7 +212,7 @@ <h5 class="mb-2">Social network profiles</h5>
215212
type="text"
216213
id="Facebook"
217214
placeholder="Username"
218-
[(ngModel)]="currentUser.facebook"
215+
[(ngModel)]="currentUserForUpdating.facebook"
219216
/>
220217
</li>
221218

@@ -226,7 +223,7 @@ <h5 class="mb-2">Social network profiles</h5>
226223
type="text"
227224
id="Twitter"
228225
placeholder="Username"
229-
[(ngModel)]="currentUser.twitter"
226+
[(ngModel)]="currentUserForUpdating.twitter"
230227
/>
231228
</li>
232229
</ul>
@@ -238,7 +235,7 @@ <h5 class="mb-2">Social network profiles</h5>
238235
type="text"
239236
id="Instagram"
240237
placeholder="Username"
241-
[(ngModel)]="currentUser.instagram"
238+
[(ngModel)]="currentUserForUpdating.instagram"
242239
/>
243240
</li>
244241

@@ -249,7 +246,7 @@ <h5 class="mb-2">Social network profiles</h5>
249246
type="text"
250247
id="LinkedIn"
251248
placeholder="Username"
252-
[(ngModel)]="currentUser.linkedIn"
249+
[(ngModel)]="currentUserForUpdating.linkedIn"
253250
/>
254251
</li>
255252
</ul>

MangoAPI.Client/src/app/components/settings/settings.component.ts

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,26 @@ export class SettingsComponent implements OnInit, OnDestroy {
5151
publicKey: 0,
5252
pictureUrl: ''
5353
};
54+
55+
public currentUserForUpdating: User = {
56+
userId: '',
57+
displayName: '',
58+
displayNameColour: 0,
59+
birthdayDate: '',
60+
email: '',
61+
website: '',
62+
username: '',
63+
bio: '',
64+
userNameChanged: false,
65+
address: '',
66+
facebook: '',
67+
twitter: '',
68+
instagram: '',
69+
linkedIn: '',
70+
publicKey: 0,
71+
pictureUrl: ''
72+
};
73+
5474
public currentUserId = '';
5575
public changePasswordCommand: ChangePasswordCommand = {
5676
currentPassword: '',
@@ -80,6 +100,7 @@ export class SettingsComponent implements OnInit, OnDestroy {
80100
.subscribe({
81101
next: (response) => {
82102
this.currentUser = response.user;
103+
this.currentUserForUpdating = {...response.user};
83104

84105
if (response.user.userNameChanged === false) {
85106
this.currentUser.username = '';
@@ -133,36 +154,22 @@ export class SettingsComponent implements OnInit, OnDestroy {
133154
});
134155
}
135156

136-
onLogoutAllClick(): void {
137-
this._sessionService
138-
.deleteAllSessions()
139-
.pipe(takeUntil(this.componentDestroyed$))
140-
.subscribe({
141-
next: (_) => {
142-
this._tokensService.clearTokens();
143-
this._router.navigateByUrl('login').then((r) => r);
144-
},
145-
error: (error) => {
146-
this._errorNotificationService.notifyOnError(error);
147-
}
148-
});
149-
}
150-
151157
onSaveChangesAccountInfoClick(): void {
152158
const command: UpdateAccountInformationCommand = {
153-
username: this.currentUser.username,
154-
birthdayDate: this.currentUser.birthdayDate,
155-
website: this.currentUser.website,
156-
address: this.currentUser.address,
157-
bio: this.currentUser.bio,
158-
displayName: this.currentUser.displayName
159+
username: this.currentUserForUpdating.username,
160+
birthdayDate: this.currentUserForUpdating.birthdayDate,
161+
website: this.currentUserForUpdating.website,
162+
address: this.currentUserForUpdating.address,
163+
bio: this.currentUserForUpdating.bio,
164+
displayName: this.currentUserForUpdating.displayName
159165
};
160166

161167
this._usersService
162168
.updateUserAccountInformation(command)
163169
.pipe(takeUntil(this.componentDestroyed$))
164170
.subscribe({
165171
next: (response) => {
172+
this.currentUser = {...this.currentUserForUpdating};
166173
this.currentUser.userNameChanged = true;
167174
alert(response.message);
168175
},

MangoAPI.Client/src/app/interceptors/auth-interceptor.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class AuthInterceptor implements HttpInterceptor {
2929
err.status === 401 &&
3030
request.headers.has('Authorization') &&
3131
request.headers.get('Authorization')?.startsWith('Bearer');
32-
32+
3333
if (shouldHandle) {
3434
const refreshToken = this.tokensService.getTokens()?.refreshToken ?? '';
3535

MangoAPI.IntegrationTests/ApiCommandsTests/LogoutAllCommandHandlerTests/LogoutAllTestSuccess.cs

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

MangoAPI.Presentation/Controllers/SessionsController.cs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -96,26 +96,4 @@ public async Task<IActionResult> LogoutAsync(
9696

9797
return await RequestAsync(command, cancellationToken);
9898
}
99-
100-
/// <summary>
101-
/// Deletes all current user's sessions.
102-
/// </summary>
103-
/// <param name="cancellationToken">Cancellation token instance.</param>
104-
/// <returns>Possible codes: 200, 400, 409.</returns>
105-
[HttpDelete]
106-
[Authorize]
107-
[SwaggerOperation(
108-
Description = "Deletes all current user's sessions.",
109-
Summary = "Deletes all current user's sessions.")]
110-
[ProducesResponseType(typeof(ResponseBase), StatusCodes.Status200OK)]
111-
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status400BadRequest)]
112-
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status409Conflict)]
113-
public async Task<IActionResult> LogoutAllAsync(CancellationToken cancellationToken)
114-
{
115-
var userId = CorrelationContext.GetUserId();
116-
117-
var command = new LogoutAllCommand(userId);
118-
119-
return await RequestAsync(command, cancellationToken);
120-
}
12199
}

MangoAPI.Presentation/Interfaces/ISessionsController.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,4 @@ public interface ISessionsController
1313
Task<IActionResult> RefreshSession(Guid refreshToken, CancellationToken cancellationToken);
1414

1515
Task<IActionResult> LogoutAsync(Guid refreshToken, CancellationToken cancellationToken);
16-
17-
Task<IActionResult> LogoutAllAsync(CancellationToken cancellationToken);
1816
}

0 commit comments

Comments
 (0)