mirror of
https://github.com/xuthus83/pigallery2.git
synced 2025-01-14 14:43:17 +08:00
Fixing sharing login issue on first load when no password needed #281
This commit is contained in:
parent
d750e7e007
commit
53c8de3695
@ -10,6 +10,7 @@ import {ErrorCodes, ErrorDTO} from '../../common/entities/Error';
|
||||
import {UserDTO} from '../../common/entities/UserDTO';
|
||||
import {ServerTimeEntry} from '../middlewares/ServerTimingMWs';
|
||||
import {ClientConfig, TAGS} from '../../common/config/public/ClientConfig';
|
||||
import {QueryParams} from '../../common/QueryParams';
|
||||
|
||||
declare global {
|
||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||
@ -65,7 +66,8 @@ export class PublicRouter {
|
||||
};
|
||||
};
|
||||
|
||||
app.use((req: Request, res: Response, next: NextFunction) => {
|
||||
const addTPl = (req: Request, res: Response, next: NextFunction) => {
|
||||
|
||||
res.tpl = {};
|
||||
|
||||
res.tpl.user = null;
|
||||
@ -100,7 +102,9 @@ export class PublicRouter {
|
||||
res.tpl.customHTMLHead = Config.Server.customHTMLHead;
|
||||
|
||||
return next();
|
||||
});
|
||||
};
|
||||
|
||||
app.use(addTPl);
|
||||
|
||||
app.get('/heartbeat', (req: Request, res: Response) => {
|
||||
res.sendStatus(200);
|
||||
@ -129,7 +133,8 @@ export class PublicRouter {
|
||||
'/',
|
||||
'/login',
|
||||
'/gallery*',
|
||||
'/share*',
|
||||
'/share/:' + QueryParams.gallery.sharingKey_params,
|
||||
'/shareLogin',
|
||||
'/admin',
|
||||
'/duplicates',
|
||||
'/faces',
|
||||
@ -137,6 +142,7 @@ export class PublicRouter {
|
||||
'/search*',
|
||||
],
|
||||
AuthenticationMWs.tryAuthenticate,
|
||||
addTPl, // add template after authentication was successful
|
||||
setLocale,
|
||||
renderIndex
|
||||
);
|
||||
|
@ -1,10 +1,10 @@
|
||||
import { AuthenticationMWs } from '../middlewares/user/AuthenticationMWs';
|
||||
import { UserRoles } from '../../common/entities/UserDTO';
|
||||
import { RenderingMWs } from '../middlewares/RenderingMWs';
|
||||
import { SharingMWs } from '../middlewares/SharingMWs';
|
||||
import {AuthenticationMWs} from '../middlewares/user/AuthenticationMWs';
|
||||
import {UserRoles} from '../../common/entities/UserDTO';
|
||||
import {RenderingMWs} from '../middlewares/RenderingMWs';
|
||||
import {SharingMWs} from '../middlewares/SharingMWs';
|
||||
import * as express from 'express';
|
||||
import { QueryParams } from '../../common/QueryParams';
|
||||
import { ServerTimingMWs } from '../middlewares/ServerTimingMWs';
|
||||
import {QueryParams} from '../../common/QueryParams';
|
||||
import {ServerTimingMWs} from '../middlewares/ServerTimingMWs';
|
||||
import {Config} from '../../common/config/private/Config';
|
||||
|
||||
export class SharingRouter {
|
||||
@ -62,7 +62,7 @@ export class SharingRouter {
|
||||
|
||||
private static addDeleteSharing(app: express.Express): void {
|
||||
app.delete(
|
||||
[Config.Server.apiPath + '/share/:sharingKey'],
|
||||
[Config.Server.apiPath + '/share/:' + QueryParams.gallery.sharingKey_params],
|
||||
AuthenticationMWs.authenticate,
|
||||
AuthenticationMWs.authorise(UserRoles.Admin),
|
||||
SharingMWs.deleteSharing,
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { LoginCredential } from '../../../../common/entities/LoginCredential';
|
||||
import { AuthenticationService } from '../../model/network/authentication.service';
|
||||
import { ErrorCodes } from '../../../../common/entities/Error';
|
||||
import { Config } from '../../../../common/config/public/Config';
|
||||
import { NavigationService } from '../../model/navigation.service';
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {LoginCredential} from '../../../../common/entities/LoginCredential';
|
||||
import {AuthenticationService} from '../../model/network/authentication.service';
|
||||
import {ErrorCodes} from '../../../../common/entities/Error';
|
||||
import {Config} from '../../../../common/config/public/Config';
|
||||
import {NavigationService} from '../../model/navigation.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-login',
|
||||
|
@ -20,7 +20,7 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr *ngFor="let share of shares">
|
||||
<td>{{share.sharingKey}}</td>
|
||||
<td><a [href]="sharingUrl + share.sharingKey">{{share.sharingKey}}</a></td>
|
||||
<td>{{share.path}}</td>
|
||||
<td>{{share.creator.name}}</td>
|
||||
<td>{{share.expires | date}}</td>
|
||||
|
@ -2,6 +2,7 @@ import {Component, OnInit} from '@angular/core';
|
||||
import {SharingDTO} from '../../../../../common/entities/SharingDTO';
|
||||
import {SharingListService} from './sharing-list.service';
|
||||
import {SettingsService} from '../settings.service';
|
||||
import {Config} from '../../../../../common/config/public/Config';
|
||||
|
||||
@Component({
|
||||
selector: 'app-settigns-sharings-list',
|
||||
@ -15,6 +16,7 @@ export class SharingsListComponent implements OnInit {
|
||||
constructor(public sharingList: SharingListService,
|
||||
private settingsService: SettingsService) {
|
||||
}
|
||||
sharingUrl = Config.Server.publicUrl + '/share/';
|
||||
|
||||
ngOnInit(): void {
|
||||
this.getSharingList();
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { AuthenticationService } from '../../model/network/authentication.service';
|
||||
import { ErrorCodes } from '../../../../common/entities/Error';
|
||||
import { Config } from '../../../../common/config/public/Config';
|
||||
import { NavigationService } from '../../model/navigation.service';
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {AuthenticationService} from '../../model/network/authentication.service';
|
||||
import {ErrorCodes} from '../../../../common/entities/Error';
|
||||
import {Config} from '../../../../common/config/public/Config';
|
||||
import {NavigationService} from '../../model/navigation.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-share-login',
|
||||
|
Loading…
x
Reference in New Issue
Block a user