Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: change project structure #2

Merged
merged 37 commits into from
Oct 4, 2024
Merged
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
5834046
feat: edit or delete unnecessary files and projects
HlibPavlyk Sep 1, 2024
1945731
feat: update domain entities
HlibPavlyk Sep 2, 2024
0e45a68
feat: update entity type configuration
HlibPavlyk Sep 2, 2024
b018300
feat: add backend presentation layer
HlibPavlyk Sep 2, 2024
1dcc94a
feat: fix repositories
HlibPavlyk Sep 2, 2024
592ae5b
feat: improve repositories
HlibPavlyk Sep 3, 2024
45bab86
feat: fix auth service
HlibPavlyk Sep 3, 2024
c82d41f
feat: recreate base backend logic
HlibPavlyk Sep 6, 2024
0581232
feat: add patch endpoints
HlibPavlyk Sep 6, 2024
ce63ddf
feat: update repositories and entity configs
HlibPavlyk Sep 7, 2024
7c6510c
feat: complete album endpoints
HlibPavlyk Sep 7, 2024
b4c8786
feat: add unit tests for created services
HlibPavlyk Sep 7, 2024
9f9cc2f
feat: add client part based on angular
HlibPavlyk Sep 12, 2024
47a80c5
feat: add album component
HlibPavlyk Sep 15, 2024
12b26f3
feat: add album view component
HlibPavlyk Sep 15, 2024
eee7df4
feat: add top bar component
HlibPavlyk Sep 15, 2024
9eaca59
feat: add section bar
HlibPavlyk Sep 15, 2024
83783eb
feat: add basic logit to top bar
HlibPavlyk Sep 15, 2024
7b46f3a
feat: add routing
HlibPavlyk Sep 15, 2024
7b1c664
feat: add sorting to albums
HlibPavlyk Sep 23, 2024
3ebec3e
feat: update get paged albums func
HlibPavlyk Sep 24, 2024
78ab2f2
feat: implement album page get on front
HlibPavlyk Sep 24, 2024
280c95a
feat: add register/login components
HlibPavlyk Sep 25, 2024
7e2a19a
feat: add auth guard and interceptor
HlibPavlyk Sep 25, 2024
06f8871
feat: complete login component
HlibPavlyk Sep 25, 2024
d933979
feat: complete register component
HlibPavlyk Sep 25, 2024
eeb33c4
feat: add album-form component
HlibPavlyk Sep 25, 2024
1a71e25
chore: update auth logic
HlibPavlyk Sep 30, 2024
18b1cdb
chore: update form component
HlibPavlyk Sep 30, 2024
b8b86e3
feat: add user service and controller
HlibPavlyk Oct 3, 2024
2adc8c3
feat: add some album service methods
HlibPavlyk Oct 3, 2024
ba1094d
feat: update album view component
HlibPavlyk Oct 3, 2024
6e88355
feat: add profile component
HlibPavlyk Oct 3, 2024
ad0ede9
chore: make some fixes
HlibPavlyk Oct 3, 2024
67b4953
feat: add stats component
HlibPavlyk Oct 3, 2024
3c52f68
feat: add author row to album cards
HlibPavlyk Oct 4, 2024
7825fbf
feat: update link to user profile
HlibPavlyk Oct 4, 2024
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
Prev Previous commit
Next Next commit
chore: update auth logic
- fix top bar user mapping
- fix intercepter
HlibPavlyk committed Sep 30, 2024
commit 1a71e25a3cc9d9cd4e14ff52cbf5fa78601afbbc
5 changes: 3 additions & 2 deletions src/CoinyProject.Api/Program.cs
Original file line number Diff line number Diff line change
@@ -50,8 +50,9 @@
corsPolicyBuilder =>
{
corsPolicyBuilder.WithOrigins("http://localhost:4200")
.AllowAnyHeader()
.AllowAnyMethod();
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
});
});

2 changes: 1 addition & 1 deletion src/CoinyProject.Api/appsettings.json
Original file line number Diff line number Diff line change
@@ -12,6 +12,6 @@
"Jwt": {
"Key": "thisisasecretkeyanditsmorelengthiernow",
"Issuer": "https://localhost:7218",
"Audience": "https://localhost:4200"
"Audience": "http://localhost:4200"
}
}
20 changes: 13 additions & 7 deletions src/CoinyProject.Client/src/app/app.routes.ts
Original file line number Diff line number Diff line change
@@ -4,19 +4,25 @@ import {AlbumComponent} from "./album/album.component";
import {LoginComponent} from "./login/login.component";
import {RegisterComponent} from "./register/register.component";
import {AlbumFormComponent} from "./album/album-form/album-form.component";
import {authGuard} from "./guards/auth.guard";

export const routes: Routes = [
//{ path: '', redirectTo: 'albums', pathMatch: 'full' },
{ path: 'albums', component: AlbumComponent },
{ path: 'info', component: InfoComponent },
{ path: 'login', component: LoginComponent },
{ path: 'register', component: RegisterComponent },
{ path: 'album-create', component: AlbumFormComponent },
{ path: 'album-edit', component: AlbumFormComponent },
/*{
path: 'employees',
component: EmployeeComponent,
{
path: 'album-create',
component: AlbumFormComponent,
canActivate: [authGuard],
data: { roles: ['Administrator', 'HRManager', 'ProjectManager'] }
},*/
data: { roles: ['User'] }
},
{
path: 'album-edit/:id',
component: AlbumFormComponent,
canActivate: [authGuard],
data: { roles: ['User'] }
},

]
7 changes: 6 additions & 1 deletion src/CoinyProject.Client/src/app/login/login.component.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
<!-- login.component.html -->
<div class="flex justify-center items-center h-screen bg-yellow-100">
<div class="flex justify-center items-center mt-20 bg-yellow-100">
<div class="w-full max-w-md bg-white shadow-lg rounded-lg p-8">
<h2 class="text-3xl font-bold mb-6 text-center text-yellow-600">Login</h2>

<!-- Error message -->
<div *ngIf="errorMessage" class="text-red-600 bg-red-100 p-3 rounded mb-4">
{{ errorMessage }}
</div>

<form (ngSubmit)="onLoginFormSubmit()" class="space-y-6">
<!-- Email or Username -->
<div>
8 changes: 5 additions & 3 deletions src/CoinyProject.Client/src/app/login/login.component.ts
Original file line number Diff line number Diff line change
@@ -4,13 +4,15 @@ import {AuthService} from "../services/auth.service";
import {FormsModule} from "@angular/forms";
import {LoginRequestDto} from "./login-request.module";
import {CookieService} from "ngx-cookie-service";
import {NgIf} from "@angular/common";

@Component({
selector: 'app-login',
standalone: true,
imports: [
FormsModule
],
imports: [
FormsModule,
NgIf
],
templateUrl: './login.component.html',
styleUrl: './login.component.css'
})
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- register.component.html -->
<div class="flex justify-center items-center h-screen bg-yellow-100">
<div class="flex justify-center items-center mt-12 bg-yellow-100">
<div class="w-full max-w-md bg-white shadow-lg rounded-lg p-8">
<h2 class="text-3xl font-bold mb-6 text-center text-yellow-600">Register</h2>

8 changes: 7 additions & 1 deletion src/CoinyProject.Client/src/app/services/auth.service.ts
Original file line number Diff line number Diff line change
@@ -27,10 +27,15 @@ export class AuthService {
}

setUser(user: UserModel): void {
this.userSubject.next(user);
localStorage.setItem('user-name', user.username);
localStorage.setItem('user-email', user.email);
localStorage.setItem('user-roles', user.roles.join());
this.userSubject.next(user);
}

isTokenExpired(token: string): boolean {
const expiry = (JSON.parse(atob(token.split('.')[1]))).exp;
return (Math.floor((new Date).getTime() / 1000)) >= expiry;
}

user(): Observable<UserModel | undefined> {
@@ -52,6 +57,7 @@ export class AuthService {
return undefined;
}


logout(): void {
localStorage.clear();
this.cookieService.delete('Authorization', '/');
13 changes: 7 additions & 6 deletions src/CoinyProject.Client/src/app/top-bar/top-bar.component.ts
Original file line number Diff line number Diff line change
@@ -35,17 +35,18 @@ export class TopBarComponent implements OnInit{
constructor(protected authService: AuthService, private router: Router) { }

ngOnInit() {
this.authService.user().subscribe(user => {
if (user) {
this.user = user;
console.log(`User is logged in as ${user.email}`);
this.authService.user().subscribe(() => {
this.user = this.authService.getUser();
if (this.user) {
console.log(`User is logged in as ${this.user.email}`);
} else {
console.log('User is not logged in');
}
});
this.user = this.authService.getUser();
}

onLogout(): void{
this.user = undefined;
//this.user = undefined;
this.authService.logout();
this.router.navigate(['login']);
console.log('User is logged out');
15 changes: 12 additions & 3 deletions src/CoinyProject.Client/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import { bootstrapApplication } from '@angular/platform-browser';
import { appConfig } from './app/app.config';
import { AppComponent } from './app/app.component';
import {provideRouter} from "@angular/router";
import {routes} from "./app/app.routes";
import {importProvidersFrom} from "@angular/core";
import {HTTP_INTERCEPTORS, HttpClientModule} from "@angular/common/http";
import {AuthInterceptor} from "./app/interceptors/auth.interceptor";

bootstrapApplication(AppComponent, appConfig)
.catch((err) => console.error(err));
bootstrapApplication(AppComponent, {
providers: [
provideRouter(routes),
importProvidersFrom(HttpClientModule),
{ provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true }
]
}).catch(err => console.error(err));