Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

6 changes: 3 additions & 3 deletions MangoAPI.BusinessLogic/MangoAPI.BusinessLogic.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\MangoAPI.Application\MangoAPI.Application.csproj"/>
<ProjectReference Include="..\MangoAPI.Infrastructure\MangoAPI.Infrastructure.csproj"/>
<ProjectReference Include="..\MangoAPI.Domain\MangoAPI.Domain.csproj"/>
<ProjectReference Include="..\MangoAPI.Application\MangoAPI.Application.csproj" />
<ProjectReference Include="..\MangoAPI.Infrastructure\MangoAPI.Infrastructure.csproj" />
<ProjectReference Include="..\MangoAPI.Domain\MangoAPI.Domain.csproj" />
</ItemGroup>
</Project>
23 changes: 10 additions & 13 deletions MangoAPI.Client/src/app/components/settings/settings.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ <h5>Profile</h5>
<button class="button-dark py-2 contact-button px-4" (click)="onLogoutClick()">
Logout
</button>
<button class="button-dark py-2 contact-button px-4 ml-3" (click)="onLogoutAllClick()">
Logout All Devices
</button>
</div>
</div>
<ul class="user-info">
Expand Down Expand Up @@ -135,7 +132,7 @@ <h5 class="mb-2">Account</h5>
value="{{ currentUser.birthdayDate }}"
id="BirthdayDate"
placeholder="Type your birthday"
[(ngModel)]="currentUser.birthdayDate"
[(ngModel)]="currentUserForUpdating.birthdayDate"
/>
</li>

Expand All @@ -146,7 +143,7 @@ <h5 class="mb-2">Account</h5>
type="text"
id="Website"
placeholder="Type your website"
[(ngModel)]="currentUser.website"
[(ngModel)]="currentUserForUpdating.website"
/>
</li>
</ul>
Expand All @@ -158,7 +155,7 @@ <h5 class="mb-2">Account</h5>
type="text"
id="UserName"
placeholder="Type your user name"
[(ngModel)]="currentUser.username"
[(ngModel)]="currentUserForUpdating.username"
/>
</li>

Expand All @@ -169,7 +166,7 @@ <h5 class="mb-2">Account</h5>
type="text"
id="DisplayName"
placeholder="Type your display name"
[(ngModel)]="currentUser.displayName"
[(ngModel)]="currentUserForUpdating.displayName"
/>
</li>
</ul>
Expand All @@ -180,7 +177,7 @@ <h5 class="mb-2">Account</h5>
type="text"
id="Bio"
placeholder="Type your bio"
[(ngModel)]="currentUser.bio"
[(ngModel)]="currentUserForUpdating.bio"
/>
</div>
<div class="d-flex flex-column profile-form-group">
Expand All @@ -190,7 +187,7 @@ <h5 class="mb-2">Account</h5>
type="text"
id="Address"
placeholder="Type your address"
[(ngModel)]="currentUser.address"
[(ngModel)]="currentUserForUpdating.address"
/>
</div>
</div>
Expand All @@ -215,7 +212,7 @@ <h5 class="mb-2">Social network profiles</h5>
type="text"
id="Facebook"
placeholder="Username"
[(ngModel)]="currentUser.facebook"
[(ngModel)]="currentUserForUpdating.facebook"
/>
</li>

Expand All @@ -226,7 +223,7 @@ <h5 class="mb-2">Social network profiles</h5>
type="text"
id="Twitter"
placeholder="Username"
[(ngModel)]="currentUser.twitter"
[(ngModel)]="currentUserForUpdating.twitter"
/>
</li>
</ul>
Expand All @@ -238,7 +235,7 @@ <h5 class="mb-2">Social network profiles</h5>
type="text"
id="Instagram"
placeholder="Username"
[(ngModel)]="currentUser.instagram"
[(ngModel)]="currentUserForUpdating.instagram"
/>
</li>

Expand All @@ -249,7 +246,7 @@ <h5 class="mb-2">Social network profiles</h5>
type="text"
id="LinkedIn"
placeholder="Username"
[(ngModel)]="currentUser.linkedIn"
[(ngModel)]="currentUserForUpdating.linkedIn"
/>
</li>
</ul>
Expand Down
49 changes: 28 additions & 21 deletions MangoAPI.Client/src/app/components/settings/settings.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,26 @@ export class SettingsComponent implements OnInit, OnDestroy {
publicKey: 0,
pictureUrl: ''
};

public currentUserForUpdating: User = {
userId: '',
displayName: '',
displayNameColour: 0,
birthdayDate: '',
email: '',
website: '',
username: '',
bio: '',
userNameChanged: false,
address: '',
facebook: '',
twitter: '',
instagram: '',
linkedIn: '',
publicKey: 0,
pictureUrl: ''
};

public currentUserId = '';
public changePasswordCommand: ChangePasswordCommand = {
currentPassword: '',
Expand Down Expand Up @@ -80,6 +100,7 @@ export class SettingsComponent implements OnInit, OnDestroy {
.subscribe({
next: (response) => {
this.currentUser = response.user;
this.currentUserForUpdating = {...response.user};

if (response.user.userNameChanged === false) {
this.currentUser.username = '';
Expand Down Expand Up @@ -133,36 +154,22 @@ export class SettingsComponent implements OnInit, OnDestroy {
});
}

onLogoutAllClick(): void {
this._sessionService
.deleteAllSessions()
.pipe(takeUntil(this.componentDestroyed$))
.subscribe({
next: (_) => {
this._tokensService.clearTokens();
this._router.navigateByUrl('login').then((r) => r);
},
error: (error) => {
this._errorNotificationService.notifyOnError(error);
}
});
}

onSaveChangesAccountInfoClick(): void {
const command: UpdateAccountInformationCommand = {
username: this.currentUser.username,
birthdayDate: this.currentUser.birthdayDate,
website: this.currentUser.website,
address: this.currentUser.address,
bio: this.currentUser.bio,
displayName: this.currentUser.displayName
username: this.currentUserForUpdating.username,
birthdayDate: this.currentUserForUpdating.birthdayDate,
website: this.currentUserForUpdating.website,
address: this.currentUserForUpdating.address,
bio: this.currentUserForUpdating.bio,
displayName: this.currentUserForUpdating.displayName
};

this._usersService
.updateUserAccountInformation(command)
.pipe(takeUntil(this.componentDestroyed$))
.subscribe({
next: (response) => {
this.currentUser = {...this.currentUserForUpdating};
this.currentUser.userNameChanged = true;
alert(response.message);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class AuthInterceptor implements HttpInterceptor {
err.status === 401 &&
request.headers.has('Authorization') &&
request.headers.get('Authorization')?.startsWith('Bearer');

if (shouldHandle) {
const refreshToken = this.tokensService.getTokens()?.refreshToken ?? '';

Expand Down

This file was deleted.

22 changes: 0 additions & 22 deletions MangoAPI.Presentation/Controllers/SessionsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,26 +96,4 @@ public async Task<IActionResult> LogoutAsync(

return await RequestAsync(command, cancellationToken);
}

/// <summary>
/// Deletes all current user's sessions.
/// </summary>
/// <param name="cancellationToken">Cancellation token instance.</param>
/// <returns>Possible codes: 200, 400, 409.</returns>
[HttpDelete]
[Authorize]
[SwaggerOperation(
Description = "Deletes all current user's sessions.",
Summary = "Deletes all current user's sessions.")]
[ProducesResponseType(typeof(ResponseBase), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status400BadRequest)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status409Conflict)]
public async Task<IActionResult> LogoutAllAsync(CancellationToken cancellationToken)
{
var userId = CorrelationContext.GetUserId();

var command = new LogoutAllCommand(userId);

return await RequestAsync(command, cancellationToken);
}
}
2 changes: 0 additions & 2 deletions MangoAPI.Presentation/Interfaces/ISessionsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,4 @@ public interface ISessionsController
Task<IActionResult> RefreshSession(Guid refreshToken, CancellationToken cancellationToken);

Task<IActionResult> LogoutAsync(Guid refreshToken, CancellationToken cancellationToken);

Task<IActionResult> LogoutAllAsync(CancellationToken cancellationToken);
}