Skip to content

Commit

Permalink
fix: reload
Browse files Browse the repository at this point in the history
  • Loading branch information
Der-Zauberer committed Aug 4, 2023
1 parent a9f20b0 commit 5a95def
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/app/auth-page/auth-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class AuthPageComponent implements OnInit {
constructor(private fb: FormBuilder, private router: Router, private authService: AuthService, private store: Store, private wsService: WebsocketService, private actionsService: ActionsService) {}

ngOnInit() {
localStorage.clear()
sessionStorage.clear()
this.authForm = this.fb.group({
username: ["", Validators.required],
password: ["", Validators.required]
Expand All @@ -46,8 +46,8 @@ export class AuthPageComponent implements OnInit {
} else {
this.authService.register(this.authForm.value.username, this.authForm.value.password).subscribe(
result => {
localStorage.setItem('token', result["token"])
localStorage.setItem('id', result["id"])
sessionStorage.setItem('token', result["token"])
sessionStorage.setItem('id', result["id"])
alert('Sie haben sich erfolgreich registriert!')
this.router.navigate(['/create']);
},
Expand All @@ -69,8 +69,8 @@ export class AuthPageComponent implements OnInit {
this.authService.login(this.authForm.value.username, this.authForm.value.password)
.subscribe(
result => {
localStorage.setItem('token', result["token"])
localStorage.setItem('id', result["id"])
sessionStorage.setItem('token', result["token"])
sessionStorage.setItem('id', result["id"])

this.actionsService.getSygotchi().subscribe(result => {
this.store.dispatch(setSygotchi({sygotchi: result as SyGotchi}))
Expand Down
2 changes: 1 addition & 1 deletion src/app/misc/auth.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class AuthGuard implements CanActivate {
constructor(private router: Router) {}

canActivate(): boolean {
if (localStorage.getItem('token')) {
if (sessionStorage.getItem('token')) {
return true
} else {
this.router.navigate(['/auth']);
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/actions.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class ActionsService {
constructor(private http: HttpClient) {}

getAccountInfo() {
const id = localStorage.getItem('id')
const id = sessionStorage.getItem('id')

return this.http.get(`${this.apiUrl}/user/${id}`)
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class AuthService {
}

isAuthenticated(): boolean {
const token = localStorage.getItem('token');
const token = sessionStorage.getItem('token');
return token !== '' && token !== undefined && token !== null;
}

Expand Down

0 comments on commit 5a95def

Please sign in to comment.