diff --git a/client/src/app/_guard/auth.guard.ts b/client/src/app/_guard/auth.guard.ts index c31063537027b35f498e38bd0347ab455ce1b0e6..b4146e9c8c9fa1ac4d159a4f4893a8896c2a1389 100644 --- a/client/src/app/_guard/auth.guard.ts +++ b/client/src/app/_guard/auth.guard.ts @@ -1,17 +1,29 @@ import {Injectable} from '@angular/core'; import {Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot} from '@angular/router'; +import {AuthenticationService} from '../services/auth/authentication.service'; @Injectable({providedIn: 'root'}) export class AuthGuard implements CanActivate { - constructor(private router: Router) { + constructor(private router: Router, private authenticationService: AuthenticationService) { } canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { - if (localStorage.getItem('currentUser')) { + + const currentUser = this.authenticationService.currentUserValue; + if (currentUser) { + // check if route is restricted by role + if (route.data.roles && route.data.roles.indexOf(currentUser.role) === -1) { + // role not authorised so redirect to home page + this.router.navigate(['/']); + return false; + } + + // authorised so return true return true; } + // not logged in so redirect to login page with the return url this.router.navigate(['/login'], {queryParams: {returnUrl: state.url}}); return false; } diff --git a/client/src/app/_helper/_models/roles.ts b/client/src/app/_helper/_models/roles.ts new file mode 100644 index 0000000000000000000000000000000000000000..85b6beaa524523ab44000e28955c113f851bc764 --- /dev/null +++ b/client/src/app/_helper/_models/roles.ts @@ -0,0 +1,7 @@ +export enum Role { + + shodai = 'shodai', + sensei = 'sensei', + monji = 'monji', + +} diff --git a/client/src/app/_helper/_models/user.ts b/client/src/app/_helper/_models/user.ts index 9f507ef82f0680ae0109721f2d9bd89980d1cb44..dc82e2e0dd66b508e66299aa15230ae6ee066f1b 100644 --- a/client/src/app/_helper/_models/user.ts +++ b/client/src/app/_helper/_models/user.ts @@ -1,4 +1,6 @@ export class User { id: number; username: string; + role: string; + token?: string; } diff --git a/client/src/app/_helper/error.interceptor.ts b/client/src/app/_helper/error.interceptor.ts index d9ecfdb65345ce38389c4cc6e3d7dabe0f98684b..4f5ae055edf389823c51ab517c2cffcb2752bc4e 100644 --- a/client/src/app/_helper/error.interceptor.ts +++ b/client/src/app/_helper/error.interceptor.ts @@ -12,11 +12,12 @@ export class ErrorInterceptor implements HttpInterceptor { intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { return next.handle(request).pipe(catchError(err => { - if (err.status === 401) { - // auto logout if 401 response returned from api + if ([401, 403].indexOf(err.status) !== -1) { + // auto logout if 401 Unauthorized or 403 Forbidden response returned from api this.authenticationService.logout(); location.reload(); } + const error = err; return throwError(error); })); diff --git a/client/src/app/_helper/jwt.interceptor.ts b/client/src/app/_helper/jwt.interceptor.ts index 6378ff702074f36b431e93bb152c7de6a70a2263..a0d236c06dd10c7fb73df1feac0b918a712f5a2b 100644 --- a/client/src/app/_helper/jwt.interceptor.ts +++ b/client/src/app/_helper/jwt.interceptor.ts @@ -1,13 +1,18 @@ import {Injectable} from '@angular/core'; import {HttpRequest, HttpHandler, HttpEvent, HttpInterceptor} from '@angular/common/http'; import {Observable} from 'rxjs'; +import {AuthenticationService} from '../services/auth/authentication.service'; @Injectable() export class JwtInterceptor implements HttpInterceptor { + + constructor(private authenticationService: AuthenticationService) { + } + intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { // add authorization header with jwt token if available - const currentUser = JSON.parse(localStorage.getItem('currentUser')); + const currentUser = this.authenticationService.currentUserValue; if (currentUser && currentUser.token) { request = request.clone({ setHeaders: { @@ -15,7 +20,6 @@ export class JwtInterceptor implements HttpInterceptor { } }); } - return next.handle(request); } } diff --git a/client/src/app/app-routing.module.ts b/client/src/app/app-routing.module.ts index 91c38ded301aa856798bf2cad39639c012c282dd..872d793d66ac6cb1c3911c6ecb006432dc1ff591 100644 --- a/client/src/app/app-routing.module.ts +++ b/client/src/app/app-routing.module.ts @@ -7,16 +7,19 @@ import {ProgramCreateComponent} from './component/program-create/program-create. import {KataCreateComponent} from './component/kata-create/kata-create.component'; import {LoginComponent} from './component/login/login.component'; import {AuthGuard} from './_guard/auth.guard'; +import {SearchbyComponent} from './component/searchby/searchby.component'; +import {Role} from './_helper/_models/roles'; const routes: Routes = [ {path: '', component: ProgramDisplayerComponent, canActivate: [AuthGuard]}, {path: 'login', component: LoginComponent}, - {path: 'programs', component: ProgramDisplayerComponent, canActivate: [AuthGuard]}, - {path: 'kata-displayer/:id', component: KataDisplayerComponent, canActivate: [AuthGuard]}, - {path: 'kata/:prid/:id', component: KataComponent, canActivate: [AuthGuard]}, - {path: 'program_create', component: ProgramCreateComponent, canActivate: [AuthGuard]}, - {path: 'kata_create/:id/:language', component: KataCreateComponent, canActivate: [AuthGuard]}, + {path: 'programs', component: ProgramDisplayerComponent, canActivate: [AuthGuard], data: {roles: [Role.shodai, Role.monji, Role.sensei]}}, + {path: 'search', component: SearchbyComponent, canActivate: [AuthGuard], data: {roles: [Role.shodai, Role.monji, Role.sensei]}}, + {path: 'kata-displayer/:id', component: KataDisplayerComponent, canActivate: [AuthGuard], data: {roles: [Role.shodai, Role.monji, Role.sensei]}}, + {path: 'kata/:prid/:id', component: KataComponent, canActivate: [AuthGuard], data: {roles: [Role.shodai, Role.monji, Role.sensei]}}, + {path: 'program_create', component: ProgramCreateComponent, canActivate: [AuthGuard], data: {roles: [Role.shodai, Role.sensei]}}, + {path: 'kata_create/:id/:language', component: KataCreateComponent, canActivate: [AuthGuard], data: {roles: [Role.shodai, Role.sensei]}}, {path: '**', redirectTo: ''} ]; diff --git a/client/src/app/app.component.ts b/client/src/app/app.component.ts index 6390d579b43b99d27228791fe351411b8f4d1595..de2adaf57449d2c9a4c0ae95c083e35c8013ae07 100644 --- a/client/src/app/app.component.ts +++ b/client/src/app/app.component.ts @@ -1,4 +1,7 @@ import {Component} from '@angular/core'; +import {User} from './_helper/_models/user'; +import {AuthenticationService} from './services/auth/authentication.service'; +import {Router} from '@angular/router'; @Component({ selector: 'app-root', @@ -7,5 +10,12 @@ import {Component} from '@angular/core'; }) export class AppComponent { title = 'Dojo Hepia'; + currentUser: User; + constructor( + private router: Router, + private authenticationService: AuthenticationService + ) { + this.authenticationService.currentUser.subscribe(x => this.currentUser = x); + } } diff --git a/client/src/app/component/kata-create/kata-create.component.ts b/client/src/app/component/kata-create/kata-create.component.ts index 494f0bd57b2d9dd30a1d3693f60c0863d1288915..b1b4fcd4bfdb7e2e8d865340738217a67b055d8f 100644 --- a/client/src/app/component/kata-create/kata-create.component.ts +++ b/client/src/app/component/kata-create/kata-create.component.ts @@ -45,7 +45,7 @@ export class KataCreateComponent implements OnInit { toggleOptions() { - this.options = ! this.options; + this.options = !this.options; console.log(this.options); } @@ -90,9 +90,7 @@ export class KataCreateComponent implements OnInit { nbAttempt: this.numberOfAttempt, programID: this.programId, difficulty: 'Ceinture blanche' - })).subscribe(); - - this.router.navigate(['/kata-displayer/' + this.programId + '']); + })).subscribe(data => this.router.navigate(['/kata-displayer/' + this.programId + ''])); } try(): void { diff --git a/client/src/app/component/kata-displayer/kata-displayer.component.html b/client/src/app/component/kata-displayer/kata-displayer.component.html index e8fa9b912a17ead85eac8e39768aa934f93d3fe8..015312b6ec70789de2a2b0c502a0108dbd6e11ac 100644 --- a/client/src/app/component/kata-displayer/kata-displayer.component.html +++ b/client/src/app/component/kata-displayer/kata-displayer.component.html @@ -1,23 +1,27 @@ <div style="margin:5rem 10rem 0 10rem" *ngIf="!error"> <div *ngIf="inforreceived"> <h1 class="title" style="margin:2rem 0 0 2rem;">{{programTitle}} - <br/> - <span class="subtitle">{{programSensei}} <span class="language"> {{programLanguage}}</span> + <br/> + <span class="subtitle">{{programSensei}} <span class="language"> {{programLanguage}}</span> </span> - <button mat-button style="margin:0 3rem 0 0;float:right" routerLink="/kata_create/{{idProgram}}/{{programLanguage}}">Create a new kata</button> - </h1> + <button mat-button style="margin:0 3rem 0 0;float:right" + routerLink="/kata_create/{{idProgram}}/{{programLanguage}}">Create a new kata + </button> + <button mat-button style="margin:0 3rem 0 0;float:right" (click)="subscribe()">{{subvalue}}</button> + </h1> </div> <br/> - <div *ngIf="katas"> + <div *ngIf="katas" [ngClass]="isSubscribed ? '' : 'notsub'"> <div class="d-flex flex-wrap justify-content-start"> <span *ngFor="let kata of katas"> <div class="card" style="width: 18rem;margin: 2rem" routerLink="/kata/{{idProgram}}/{{kata.id}}"> <div class="card-body"> <h5 class="card-title"><a class="title" - routerLink="/kata/{{idProgram}}/{{kata.id}}">{{kata.title}}</a><span class="difficulty">{{kata.status}}</span></h5> + routerLink="/kata/{{idProgram}}/{{kata.id}}">{{kata.title}}</a><span + class="difficulty">{{kata.status}}</span></h5> <br/> <h6 class="card-subtitle mb-2 text-muted">{{kata.difficulty}}</h6> <br/> diff --git a/client/src/app/component/kata-displayer/kata-displayer.component.scss b/client/src/app/component/kata-displayer/kata-displayer.component.scss index 6c91ebe5e0375f540e93a616aba11d88a1c84d93..c764ffc8d985e91e42b1e6a9b875ed0595bdf355 100644 --- a/client/src/app/component/kata-displayer/kata-displayer.component.scss +++ b/client/src/app/component/kata-displayer/kata-displayer.component.scss @@ -12,7 +12,13 @@ font-size:15px; color:var(--color-dark-grey) !important; } +.notsub{ + pointer-events: none; + /* for "disabled" effect */ + opacity: 0.5; + background: var(--color-dark-blue); +} * { font-family: "Helvetica Neue"; diff --git a/client/src/app/component/kata-displayer/kata-displayer.component.ts b/client/src/app/component/kata-displayer/kata-displayer.component.ts index e8827886ad108bbc15f0301eec91c3145c1ab12f..0de3e1c22997ce770d5c249ed2f61bc64eb13485 100644 --- a/client/src/app/component/kata-displayer/kata-displayer.component.ts +++ b/client/src/app/component/kata-displayer/kata-displayer.component.ts @@ -19,6 +19,8 @@ export class KataDisplayerComponent implements OnInit { programLanguage: string; programSensei: string; error = false; + subvalue: string; + isSubscribed = false; inforreceived = false; @@ -31,6 +33,15 @@ export class KataDisplayerComponent implements OnInit { ) { } + subscribe() { + this.isSubscribed = !this.isSubscribed; + if (!this.isSubscribed) { + this.subvalue = 'Subscribe'; + } else { + this.subvalue = 'Unsubscribe'; + } + } + getKatas(): void { this.idProgram = this.route.snapshot.paramMap.get('id'); this.ngxLoader.start(); @@ -52,6 +63,11 @@ export class KataDisplayerComponent implements OnInit { } ngOnInit() { + if (!this.isSubscribed) { + this.subvalue = 'Subscribe'; + } else { + this.subvalue = 'Unsubscribe'; + } this.getKatas(); } diff --git a/client/src/app/component/login/login.component.ts b/client/src/app/component/login/login.component.ts index bc3f277726d561542adda1c2688a0a56e680b383..87707751b9f71141f5f3c42d543dcc5689926015 100644 --- a/client/src/app/component/login/login.component.ts +++ b/client/src/app/component/login/login.component.ts @@ -14,7 +14,11 @@ export class LoginComponent implements OnInit { constructor(private route: ActivatedRoute, private router: Router, private auth: AuthenticationService, - private formBuilder: FormBuilder) { + private formBuilder: FormBuilder, + private authenticationService: AuthenticationService) { + if (this.authenticationService.currentUserValue) { + this.router.navigate(['/']); + } } loginForm: FormGroup; diff --git a/client/src/app/component/main-left-side-nav/main-left-side-nav.component.html b/client/src/app/component/main-left-side-nav/main-left-side-nav.component.html index 4ea638d5a531c57f62f5d61cd7571e3eefd1a2b0..09498efad358f269611d105d45814e0a6930c18d 100644 --- a/client/src/app/component/main-left-side-nav/main-left-side-nav.component.html +++ b/client/src/app/component/main-left-side-nav/main-left-side-nav.component.html @@ -1,12 +1,15 @@ <mat-sidenav-container class="sidenav-container"> <mat-sidenav #drawer class="sidenav" fixedInViewport="true" - [attr.role]="(isHandset$ | async) ? 'dialog' : 'navigation'" - [mode]="(isHandset$ | async) ? 'over' : 'side'" - [opened]="!(isHandset$ | async)"> + [attr.role]="(isHandset$ | async) ? 'dialog' : 'navigation'" + [mode]="(isHandset$ | async) ? 'over' : 'side'" + [opened]="!(isHandset$ | async)"> <mat-toolbar>DOJO HEPIA</mat-toolbar> - <mat-nav-list *ngIf="true"> + <mat-nav-list *ngIf="currentUser"> <a mat-list-item href="/programs">All programs</a> - <a mat-list-item href="/program_create">New program</a> + <div *ngIf="currentUser.role != Role.monji"> + <a mat-list-item href="/program_create">New program</a> + </div> + <a mat-list-item href="/search">Search</a> <a mat-list-item (click)="logout()">Log out</a> </mat-nav-list> </mat-sidenav> diff --git a/client/src/app/component/main-left-side-nav/main-left-side-nav.component.ts b/client/src/app/component/main-left-side-nav/main-left-side-nav.component.ts index 0f81b45897db4a162b7d21011592e99d2802d214..3d5d05820c6d144eb204a9e808123382b92e6c3b 100644 --- a/client/src/app/component/main-left-side-nav/main-left-side-nav.component.ts +++ b/client/src/app/component/main-left-side-nav/main-left-side-nav.component.ts @@ -3,6 +3,8 @@ import {BreakpointObserver, Breakpoints} from '@angular/cdk/layout'; import {Observable} from 'rxjs'; import {map} from 'rxjs/operators'; import {AuthenticationService} from '../../services/auth/authentication.service'; +import {User} from '../../_helper/_models/user'; +import {Role} from '../../_helper/_models/roles'; @Component({ @@ -12,6 +14,8 @@ import {AuthenticationService} from '../../services/auth/authentication.service' }) export class MainLeftSideNavComponent { + currentUser: User; + Role = Role; isHandset$: Observable<boolean> = this.breakpointObserver.observe(Breakpoints.Handset) .pipe( map(result => result.matches) @@ -24,6 +28,8 @@ export class MainLeftSideNavComponent { } constructor(private breakpointObserver: BreakpointObserver, private auth: AuthenticationService) { + this.currentUser = this.auth.currentUserValue; + } } diff --git a/client/src/app/component/program-create/program-create.component.ts b/client/src/app/component/program-create/program-create.component.ts index b7b454b0eabe75f3e391752adbeb738e7b29c121..cff6d7f03ec92928eddef908ff2185142c46934b 100644 --- a/client/src/app/component/program-create/program-create.component.ts +++ b/client/src/app/component/program-create/program-create.component.ts @@ -1,6 +1,8 @@ import {Component, OnInit} from '@angular/core'; import {CreateProgramService} from '../../services/program/create-program.service'; import {Router} from '@angular/router'; +import {AuthenticationService} from '../../services/auth/authentication.service'; +import {User} from '../../_helper/_models/user'; @Component({ selector: 'app-program-create', @@ -8,9 +10,11 @@ import {Router} from '@angular/router'; styleUrls: ['./program-create.component.scss'] }) export class ProgramCreateComponent implements OnInit { + currentUser: User; constructor(private createProgramService: CreateProgramService, - public router: Router) { + public router: Router, private auth: AuthenticationService) { + this.currentUser = this.auth.currentUserValue; } programTitle = ''; @@ -26,7 +30,7 @@ export class ProgramCreateComponent implements OnInit { createProgram(newkata: boolean): void { this.createProgramService.createProgram(JSON.stringify({ id: this.programToKata, - sensei: 'Shodai', + sensei: this.currentUser.username, language: this.programLanguage, nbKata: 0, title: this.programTitle, diff --git a/client/src/app/component/searchby/searchby.component.css b/client/src/app/component/searchby/searchby.component.css index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..cad61d57bb6c4a3325f97b494ac22f63779773ed 100644 --- a/client/src/app/component/searchby/searchby.component.css +++ b/client/src/app/component/searchby/searchby.component.css @@ -0,0 +1,14 @@ +input{ + + background-color: rgba(43, 47, 57, 1); + border: 1px solid rgba(63, 67, 77, 1); + border-radius: 7px; + color: rgba(236, 240, 241, 1.0); + padding: .6em 1.4em .5em .8em; +} + +input:focus{ + background-color: rgba(43, 47, 57, 1); + color: var(--color-cloud); + outline:none; +} diff --git a/client/src/app/component/searchby/searchby.component.html b/client/src/app/component/searchby/searchby.component.html index f99bdc4f2a45fbf042d5450e383b71198d7b41b7..ea1941372a16af84ea8da02fe6a54637b4f6d987 100644 --- a/client/src/app/component/searchby/searchby.component.html +++ b/client/src/app/component/searchby/searchby.component.html @@ -1,3 +1,20 @@ -<p> - searchby works! -</p> +<div class="container" style="margin-top:10%"> + <form [formGroup]="loginForm" (ngSubmit)="onSubmit()"> + <div class="form-group"> + <div class="input-group mb-3"> + <div class="input-group-prepend"> + <button class="btn btn-outline-secondary dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Tag</button> + <div class="dropdown-menu"> + <a class="dropdown-item" href="#">Action</a> + <a class="dropdown-item" href="#">Another action</a> + <a class="dropdown-item" href="#">Something else here</a> + <div role="separator" class="dropdown-divider"></div> + <a class="dropdown-item" href="#">Separated link</a> + </div> + </div> + <input type="text" class="form-control" aria-label="Text input with dropdown button"> + </div> + </div> + </form> + +</div> diff --git a/client/src/app/services/auth/authentication.service.ts b/client/src/app/services/auth/authentication.service.ts index 43f3bc3140311592ad98ed0b6d0236a43a4d71b8..f327743ad4bcc244be147043c852786a24197957 100644 --- a/client/src/app/services/auth/authentication.service.ts +++ b/client/src/app/services/auth/authentication.service.ts @@ -1,10 +1,21 @@ import {Injectable} from '@angular/core'; import {HttpClient} from '@angular/common/http'; import {map} from 'rxjs/operators'; +import {User} from '../../_helper/_models/user'; +import {BehaviorSubject, Observable} from 'rxjs'; @Injectable({providedIn: 'root'}) export class AuthenticationService { + private currentUserSubject: BehaviorSubject<User>; + public currentUser: Observable<User>; + constructor(private http: HttpClient) { + this.currentUserSubject = new BehaviorSubject<User>(JSON.parse(localStorage.getItem('currentUser'))); + this.currentUser = this.currentUserSubject.asObservable(); + } + + public get currentUserValue(): User { + return this.currentUserSubject.value; } login(username: string, password: string) { diff --git a/compilation/.idea/workspace.xml b/compilation/.idea/workspace.xml index 93e8f0f3f0056a845478f60ca3da4981379cb9ee..dd502b1c22d4b2a1607a39564cd8e4014638a712 100644 --- a/compilation/.idea/workspace.xml +++ b/compilation/.idea/workspace.xml @@ -2,22 +2,8 @@ <project version="4"> <component name="ChangeListManager"> <list default="true" id="8d8fb2c1-8426-4933-8193-ee68625cf8de" name="Default Changelist" comment=""> - <change beforePath="$PROJECT_DIR$/../client/src/app/app.module.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../client/src/app/app.module.ts" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/../client/src/app/component/main-left-side-nav/main-left-side-nav.component.html" beforeDir="false" afterPath="$PROJECT_DIR$/../client/src/app/component/main-left-side-nav/main-left-side-nav.component.html" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/../client/src/app/component/program-displayer/program-displayer.component.html" beforeDir="false" afterPath="$PROJECT_DIR$/../client/src/app/component/program-displayer/program-displayer.component.html" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/../client/src/app/component/program-displayer/program-displayer.component.scss" beforeDir="false" afterPath="$PROJECT_DIR$/../client/src/app/component/program-displayer/program-displayer.component.scss" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/../client/src/app/component/program-displayer/program-displayer.component.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../client/src/app/component/program-displayer/program-displayer.component.ts" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/src/main/java/DockerCompilation.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/DockerCompilation.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/../gateway/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../gateway/.idea/workspace.xml" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/../gateway/src/main/java/LiveDB.java" beforeDir="false" afterPath="$PROJECT_DIR$/../gateway/src/main/java/LiveDB.java" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/../gateway/src/main/java/MongoDB.java" beforeDir="false" afterPath="$PROJECT_DIR$/../gateway/src/main/java/MongoDB.java" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/../gateway/src/main/java/ProgramsDataBase.java" beforeDir="false" afterPath="$PROJECT_DIR$/../gateway/src/main/java/ProgramsDataBase.java" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/../gateway/src/main/java/app.java" beforeDir="false" afterPath="$PROJECT_DIR$/../gateway/src/main/java/app.java" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/../gateway/target/classes/LiveDB.class" beforeDir="false" afterPath="$PROJECT_DIR$/../gateway/target/classes/LiveDB.class" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/../gateway/target/classes/MongoDB.class" beforeDir="false" afterPath="$PROJECT_DIR$/../gateway/target/classes/MongoDB.class" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/../gateway/target/classes/ProgramsDataBase.class" beforeDir="false" afterPath="$PROJECT_DIR$/../gateway/target/classes/ProgramsDataBase.class" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/../gateway/target/classes/app.class" beforeDir="false" afterPath="$PROJECT_DIR$/../gateway/target/classes/app.class" afterDir="false" /> </list> <ignored path="$PROJECT_DIR$/out/" /> <ignored path="$PROJECT_DIR$/target/" /> @@ -31,44 +17,7 @@ <option name="isMigrated" value="true" /> </component> <component name="FileEditorManager"> - <leaf SIDE_TABS_SIZE_LIMIT_KEY="300"> - <file pinned="false" current-in-tab="false"> - <entry file="file://$PROJECT_DIR$/pom.xml"> - <provider selected="true" editor-type-id="text-editor"> - <state> - <caret column="22" selection-start-column="22" selection-end-column="22" /> - </state> - </provider> - </entry> - </file> - <file pinned="false" current-in-tab="false"> - <entry file="file://$PROJECT_DIR$/src/main/java/app.java"> - <provider selected="true" editor-type-id="text-editor"> - <state relative-caret-position="135"> - <caret line="10" selection-start-line="10" selection-end-line="10" /> - </state> - </provider> - </entry> - </file> - <file pinned="false" current-in-tab="true"> - <entry file="file://$PROJECT_DIR$/src/main/java/DockerCompilation.java"> - <provider selected="true" editor-type-id="text-editor"> - <state relative-caret-position="120"> - <caret line="11" column="51" lean-forward="true" selection-start-line="11" selection-start-column="51" selection-end-line="11" selection-end-column="51" /> - </state> - </provider> - </entry> - </file> - <file pinned="false" current-in-tab="false"> - <entry file="file://$PROJECT_DIR$/docker/python/dockerfile"> - <provider selected="true" editor-type-id="text-editor"> - <state> - <caret column="17" selection-start-column="17" selection-end-column="17" /> - </state> - </provider> - </entry> - </file> - </leaf> + <leaf SIDE_TABS_SIZE_LIMIT_KEY="300" /> </component> <component name="FileTemplateManagerImpl"> <option name="RECENT_TEMPLATES"> @@ -242,7 +191,7 @@ <servers /> </component> <component name="TimeTrackingManager"> - <option name="totallyTimeSpent" value="30823000" /> + <option name="totallyTimeSpent" value="30876000" /> </component> <component name="TodoView"> <todo-panel id="selected-file"> @@ -255,7 +204,6 @@ </component> <component name="ToolWindowManager"> <frame x="0" y="0" width="1920" height="1200" extended-state="6" /> - <editor active="true" /> <layout> <window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.30830672" /> <window_info id="Structure" order="1" side_tool="true" weight="0.25" /> @@ -266,7 +214,7 @@ <window_info id="Favorites" order="6" side_tool="true" /> <window_info anchor="bottom" id="Message" order="0" /> <window_info anchor="bottom" id="Find" order="1" weight="0.32891566" /> - <window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.4884956" /> + <window_info anchor="bottom" id="Run" order="2" weight="0.4884956" /> <window_info anchor="bottom" id="Debug" order="3" weight="0.39941692" /> <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" /> <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" /> @@ -359,31 +307,31 @@ </entry> <entry file="file://$PROJECT_DIR$/share_docker_file/sample.py" /> <entry file="file://$PROJECT_DIR$/share_docker_file/assert.py" /> - <entry file="file://$PROJECT_DIR$/pom.xml"> + <entry file="file://$PROJECT_DIR$/src/main/java/DockerCompilation.java"> <provider selected="true" editor-type-id="text-editor"> - <state> - <caret column="22" selection-start-column="22" selection-end-column="22" /> + <state relative-caret-position="450"> + <caret line="33" column="12" selection-start-line="33" selection-start-column="12" selection-end-line="33" selection-end-column="12" /> </state> </provider> </entry> <entry file="file://$PROJECT_DIR$/src/main/java/app.java"> <provider selected="true" editor-type-id="text-editor"> - <state relative-caret-position="135"> - <caret line="10" selection-start-line="10" selection-end-line="10" /> + <state relative-caret-position="195"> + <caret line="14" lean-forward="true" selection-start-line="14" selection-end-line="14" /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/docker/python/dockerfile"> + <entry file="file://$PROJECT_DIR$/pom.xml"> <provider selected="true" editor-type-id="text-editor"> <state> - <caret column="17" selection-start-column="17" selection-end-column="17" /> + <caret column="22" selection-start-column="22" selection-end-column="22" /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/src/main/java/DockerCompilation.java"> + <entry file="file://$PROJECT_DIR$/docker/python/dockerfile"> <provider selected="true" editor-type-id="text-editor"> - <state relative-caret-position="120"> - <caret line="11" column="51" lean-forward="true" selection-start-line="11" selection-start-column="51" selection-end-line="11" selection-end-column="51" /> + <state> + <caret column="17" selection-start-column="17" selection-end-column="17" /> </state> </provider> </entry> diff --git a/gateway/.idea/workspace.xml b/gateway/.idea/workspace.xml index f96ceccd2db4a2b0c498523c6c257ac1736a1e31..5b4af594f1caed779a10298082ba347691954912 100644 --- a/gateway/.idea/workspace.xml +++ b/gateway/.idea/workspace.xml @@ -2,12 +2,21 @@ <project version="4"> <component name="ChangeListManager"> <list default="true" id="e6a1f2e5-4f60-4227-82bb-83eb10fa94a5" name="Default Changelist" comment=""> + <change afterPath="$PROJECT_DIR$/../client/src/app/_helper/_models/roles.ts" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../client/src/app/_guard/auth.guard.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../client/src/app/_guard/auth.guard.ts" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../client/src/app/_helper/_models/user.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../client/src/app/_helper/_models/user.ts" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../client/src/app/_helper/error.interceptor.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../client/src/app/_helper/error.interceptor.ts" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../client/src/app/_helper/jwt.interceptor.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../client/src/app/_helper/jwt.interceptor.ts" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../client/src/app/app-routing.module.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../client/src/app/app-routing.module.ts" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../client/src/app/app.component.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../client/src/app/app.component.ts" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../client/src/app/component/login/login.component.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../client/src/app/component/login/login.component.ts" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../client/src/app/component/main-left-side-nav/main-left-side-nav.component.html" beforeDir="false" afterPath="$PROJECT_DIR$/../client/src/app/component/main-left-side-nav/main-left-side-nav.component.html" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../client/src/app/component/searchby/searchby.component.css" beforeDir="false" afterPath="$PROJECT_DIR$/../client/src/app/component/searchby/searchby.component.css" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../client/src/app/component/searchby/searchby.component.html" beforeDir="false" afterPath="$PROJECT_DIR$/../client/src/app/component/searchby/searchby.component.html" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/../client/src/app/services/auth/authentication.service.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../client/src/app/services/auth/authentication.service.ts" afterDir="false" /> <change beforePath="$PROJECT_DIR$/../compilation/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../compilation/.idea/workspace.xml" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/../compilation/src/main/java/DockerCompilation.java" beforeDir="false" afterPath="$PROJECT_DIR$/../compilation/src/main/java/DockerCompilation.java" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/../compilation/target/classes/DockerCompilation.class" beforeDir="false" afterPath="$PROJECT_DIR$/../compilation/target/classes/DockerCompilation.class" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/src/main/java/LiveDB.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/LiveDB.java" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/main/java/MongoDB.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/MongoDB.java" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/src/main/java/ProgramsDataBase.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/ProgramsDataBase.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/main/java/app.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/app.java" afterDir="false" /> </list> <ignored path="$PROJECT_DIR$/out/" /> @@ -40,20 +49,31 @@ <file pinned="false" current-in-tab="false"> <entry file="file://$PROJECT_DIR$/pom.xml"> <provider selected="true" editor-type-id="text-editor"> - <state relative-caret-position="945"> + <state relative-caret-position="1245"> <caret line="83" column="4" selection-start-line="83" selection-start-column="4" selection-end-line="83" selection-end-column="4" /> </state> </provider> </entry> </file> - <file pinned="false" current-in-tab="true"> + <file pinned="false" current-in-tab="false"> <entry file="file://$PROJECT_DIR$/src/main/java/app.java"> <provider selected="true" editor-type-id="text-editor"> - <state relative-caret-position="488"> - <caret line="108" column="10" selection-start-line="108" selection-start-column="10" selection-end-line="108" selection-end-column="10" /> + <state relative-caret-position="195"> + <caret line="158" column="12" selection-start-line="158" selection-start-column="12" selection-end-line="158" selection-end-column="12" /> + <folding> + <element signature="imports" expanded="true" /> + </folding> + </state> + </provider> + </entry> + </file> + <file pinned="false" current-in-tab="true"> + <entry file="file://$PROJECT_DIR$/src/main/java/MongoDB.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="427"> + <caret line="118" column="69" selection-start-line="118" selection-start-column="69" selection-end-line="118" selection-end-column="69" /> <folding> <element signature="imports" expanded="true" /> - <element signature="e#1996#2010#0" expanded="true" /> </folding> </state> </provider> @@ -62,8 +82,8 @@ <file pinned="false" current-in-tab="false"> <entry file="file://$PROJECT_DIR$/src/main/java/ProgramsDataBase.java"> <provider selected="true" editor-type-id="text-editor"> - <state relative-caret-position="135"> - <caret line="9" column="74" selection-start-line="9" selection-start-column="74" selection-end-line="9" selection-end-column="74" /> + <state relative-caret-position="165"> + <caret line="11" selection-start-line="11" selection-end-line="11" /> </state> </provider> </entry> @@ -81,6 +101,7 @@ <findStrings> <find>handler</find> <find>get_id</find> + <find>slee</find> </findStrings> </component> <component name="Git.Settings"> @@ -101,8 +122,8 @@ <option value="$PROJECT_DIR$/pom.xml" /> <option value="$PROJECT_DIR$/src/main/java/ProgramsDataBase.java" /> <option value="$PROJECT_DIR$/src/main/java/LiveDB.java" /> - <option value="$PROJECT_DIR$/src/main/java/MongoDB.java" /> <option value="$PROJECT_DIR$/src/main/java/app.java" /> + <option value="$PROJECT_DIR$/src/main/java/MongoDB.java" /> </list> </option> </component> @@ -133,8 +154,8 @@ </option> </component> <component name="ProjectFrameBounds" fullScreen="true"> - <option name="width" value="1920" /> - <option name="height" value="1200" /> + <option name="width" value="1440" /> + <option name="height" value="900" /> </component> <component name="ProjectLevelVcsManager" settingsEditedManually="true"> <ConfirmationsSetting value="1" id="Add" /> @@ -145,6 +166,7 @@ </navigator> <panes> <pane id="PackagesPane" /> + <pane id="Scope" /> <pane id="ProjectPane"> <subPane> <expand> @@ -174,7 +196,6 @@ <select /> </subPane> </pane> - <pane id="Scope" /> </panes> </component> <component name="PropertiesComponent"> @@ -250,11 +271,12 @@ <workItem from="1557469406279" duration="5073000" /> <workItem from="1557487918416" duration="1045000" /> <workItem from="1557490543401" duration="4129000" /> + <workItem from="1557515924719" duration="2305000" /> </task> <servers /> </component> <component name="TimeTrackingManager"> - <option name="totallyTimeSpent" value="82244000" /> + <option name="totallyTimeSpent" value="84831000" /> </component> <component name="TodoView"> <todo-panel id="selected-file"> @@ -266,10 +288,10 @@ </todo-panel> </component> <component name="ToolWindowManager"> - <frame x="0" y="0" width="1920" height="1200" extended-state="0" /> + <frame x="0" y="0" width="1440" height="900" extended-state="0" /> <editor active="true" /> <layout> - <window_info content_ui="combo" id="Project" order="0" sideWeight="0.49924126" visible="true" weight="0.157082" /> + <window_info active="true" content_ui="combo" id="Project" order="0" sideWeight="0.49924126" visible="true" weight="0.15879828" /> <window_info id="Structure" order="1" sideWeight="0.5007587" side_tool="true" weight="0.20127796" /> <window_info id="Image Layers" order="2" /> <window_info id="Designer" order="3" /> @@ -278,7 +300,7 @@ <window_info id="Favorites" order="6" side_tool="true" /> <window_info anchor="bottom" id="Message" order="0" /> <window_info anchor="bottom" id="Find" order="1" weight="0.32920355" /> - <window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.35929203" /> + <window_info anchor="bottom" id="Run" order="2" visible="true" weight="0.35903615" /> <window_info anchor="bottom" id="Debug" order="3" weight="0.39911506" /> <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" /> <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" /> @@ -433,20 +455,6 @@ </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/pom.xml"> - <provider selected="true" editor-type-id="text-editor"> - <state relative-caret-position="945"> - <caret line="83" column="4" selection-start-line="83" selection-start-column="4" selection-end-line="83" selection-end-column="4" /> - </state> - </provider> - </entry> - <entry file="file://$PROJECT_DIR$/src/main/java/ProgramsDataBase.java"> - <provider selected="true" editor-type-id="text-editor"> - <state relative-caret-position="135"> - <caret line="9" column="74" selection-start-line="9" selection-start-column="74" selection-end-line="9" selection-end-column="74" /> - </state> - </provider> - </entry> <entry file="file://$PROJECT_DIR$/src/main/java/LiveDB.java"> <provider selected="true" editor-type-id="text-editor"> <state relative-caret-position="542"> @@ -458,13 +466,6 @@ </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/src/main/java/MongoDB.java"> - <provider selected="true" editor-type-id="text-editor"> - <state relative-caret-position="75"> - <caret line="5" lean-forward="true" selection-start-line="5" selection-end-line="5" /> - </state> - </provider> - </entry> <entry file="file://$PROJECT_DIR$/src/main/java/Program.java"> <provider selected="true" editor-type-id="text-editor"> <state relative-caret-position="540"> @@ -509,13 +510,36 @@ </state> </provider> </entry> + <entry file="file://$PROJECT_DIR$/pom.xml"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="1245"> + <caret line="83" column="4" selection-start-line="83" selection-start-column="4" selection-end-line="83" selection-end-column="4" /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/src/main/java/ProgramsDataBase.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="165"> + <caret line="11" selection-start-line="11" selection-end-line="11" /> + </state> + </provider> + </entry> <entry file="file://$PROJECT_DIR$/src/main/java/app.java"> <provider selected="true" editor-type-id="text-editor"> - <state relative-caret-position="488"> - <caret line="108" column="10" selection-start-line="108" selection-start-column="10" selection-end-line="108" selection-end-column="10" /> + <state relative-caret-position="195"> + <caret line="158" column="12" selection-start-line="158" selection-start-column="12" selection-end-line="158" selection-end-column="12" /> + <folding> + <element signature="imports" expanded="true" /> + </folding> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/src/main/java/MongoDB.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="427"> + <caret line="118" column="69" selection-start-line="118" selection-start-column="69" selection-end-line="118" selection-end-column="69" /> <folding> <element signature="imports" expanded="true" /> - <element signature="e#1996#2010#0" expanded="true" /> </folding> </state> </provider> diff --git a/gateway/src/main/java/MongoDB.java b/gateway/src/main/java/MongoDB.java index d9769c3faf926c30bf7e4fd6fe225d26cbb4e963..7b49dbd7122f878a8538c57105b9c9d7845442ab 100644 --- a/gateway/src/main/java/MongoDB.java +++ b/gateway/src/main/java/MongoDB.java @@ -111,4 +111,10 @@ public class MongoDB extends ProgramsDataBase { return p; } + + public toggleSubscription + + // [iduser, idprogram : 234, status : 1 , katas [{id:1,status:"resolved",mysol:".."}],done : 1] + // ou + // separer en deux tables ,plus simple surement pour les requetes } diff --git a/gateway/src/main/java/app.java b/gateway/src/main/java/app.java index c378b8f8e9ef5d04b9d81ddfc533f158af8a2c5b..4c95f992c2db5127ac31a85ebe0ac0884d5abcb6 100644 --- a/gateway/src/main/java/app.java +++ b/gateway/src/main/java/app.java @@ -106,7 +106,7 @@ public class app { e.printStackTrace(); } - },roles(Roles.SHODAI, Roles.SENSEI, Roles.MONJI)); + }, roles(Roles.SHODAI, Roles.SENSEI, Roles.MONJI)); app.post("/program/create", ctx -> { Program prg = objectMapper.readValue(ctx.body(), Program.class); @@ -155,7 +155,6 @@ public class app { app.post("jwt/request/", ctx -> { MockUser u = checkUser(ctx); - Thread.sleep(2000); if (!(u == null)) { String token = provider.generateToken(u); diff --git a/gateway/target/classes/app.class b/gateway/target/classes/app.class index fb7a92deda977c4a2a4e32f135cdc907d1e86295..697229182d9509dbd8797e06e91138e4b9218c1d 100644 Binary files a/gateway/target/classes/app.class and b/gateway/target/classes/app.class differ diff --git a/mongodb/newnuser b/mongodb/newnuser new file mode 100644 index 0000000000000000000000000000000000000000..24edbe0ff953f2fd59fecb5d457310b798df072a --- /dev/null +++ b/mongodb/newnuser @@ -0,0 +1,12 @@ +docker-compose exec mongo mongo admin -u root -> example + +use DojoHepia +db.createUser( + { + user: "shodai", + pwd: "shodai", + roles: [ + { role: "readWrite", db: "DojoHepia" } + ] + } +) \ No newline at end of file