mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-04-23 08:03:19 +03:00
Removed pin setting functionality
- Simplifies security options: use multi user mode if you want to restrict access to the settings menu
This commit is contained in:
@@ -96,7 +96,6 @@ db.defaults(
|
|||||||
configWriteFlag: false,
|
configWriteFlag: false,
|
||||||
downloads: {},
|
downloads: {},
|
||||||
subscriptions: [],
|
subscriptions: [],
|
||||||
pin_md5: '',
|
|
||||||
files_to_db_migration_complete: false
|
files_to_db_migration_complete: false
|
||||||
}).write();
|
}).write();
|
||||||
|
|
||||||
@@ -2623,49 +2622,6 @@ app.post('/api/updateServer', async (req, res) => {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Pin API calls
|
|
||||||
|
|
||||||
app.post('/api/isPinSet', async (req, res) => {
|
|
||||||
let stored_pin = db.get('pin_md5').value();
|
|
||||||
let is_set = false;
|
|
||||||
if (!stored_pin || stored_pin.length === 0) {
|
|
||||||
} else {
|
|
||||||
is_set = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
res.send({
|
|
||||||
is_set: is_set
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
app.post('/api/setPin', async (req, res) => {
|
|
||||||
let unhashed_pin = req.body.pin;
|
|
||||||
let hashed_pin = md5(unhashed_pin);
|
|
||||||
|
|
||||||
db.set('pin_md5', hashed_pin).write();
|
|
||||||
|
|
||||||
res.send({
|
|
||||||
success: true
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
app.post('/api/checkPin', async (req, res) => {
|
|
||||||
let input_pin = req.body.input_pin;
|
|
||||||
let input_pin_md5 = md5(input_pin);
|
|
||||||
|
|
||||||
let stored_pin = db.get('pin_md5').value();
|
|
||||||
|
|
||||||
let successful = false;
|
|
||||||
|
|
||||||
if (input_pin_md5 === stored_pin) {
|
|
||||||
successful = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
res.send({
|
|
||||||
success: successful
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// API Key API calls
|
// API Key API calls
|
||||||
|
|
||||||
app.post('/api/generateNewAPIKey', function (req, res) {
|
app.post('/api/generateNewAPIKey', function (req, res) {
|
||||||
|
|||||||
@@ -66,10 +66,6 @@ let CONFIG_ITEMS = {
|
|||||||
'key': 'ytdl_allow_multi_download_mode',
|
'key': 'ytdl_allow_multi_download_mode',
|
||||||
'path': 'YoutubeDLMaterial.Extra.allow_multi_download_mode'
|
'path': 'YoutubeDLMaterial.Extra.allow_multi_download_mode'
|
||||||
},
|
},
|
||||||
'ytdl_settings_pin_required': {
|
|
||||||
'key': 'ytdl_settings_pin_required',
|
|
||||||
'path': 'YoutubeDLMaterial.Extra.settings_pin_required'
|
|
||||||
},
|
|
||||||
'ytdl_enable_downloads_manager': {
|
'ytdl_enable_downloads_manager': {
|
||||||
'key': 'ytdl_enable_downloads_manager',
|
'key': 'ytdl_enable_downloads_manager',
|
||||||
'path': 'YoutubeDLMaterial.Extra.enable_downloads_manager'
|
'path': 'YoutubeDLMaterial.Extra.enable_downloads_manager'
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import { Router, NavigationStart, NavigationEnd } from '@angular/router';
|
|||||||
import { OverlayContainer } from '@angular/cdk/overlay';
|
import { OverlayContainer } from '@angular/cdk/overlay';
|
||||||
import { THEMES_CONFIG } from '../themes';
|
import { THEMES_CONFIG } from '../themes';
|
||||||
import { SettingsComponent } from './settings/settings.component';
|
import { SettingsComponent } from './settings/settings.component';
|
||||||
import { CheckOrSetPinDialogComponent } from './dialogs/check-or-set-pin-dialog/check-or-set-pin-dialog.component';
|
|
||||||
import { AboutDialogComponent } from './dialogs/about-dialog/about-dialog.component';
|
import { AboutDialogComponent } from './dialogs/about-dialog/about-dialog.component';
|
||||||
import { UserProfileDialogComponent } from './dialogs/user-profile-dialog/user-profile-dialog.component';
|
import { UserProfileDialogComponent } from './dialogs/user-profile-dialog/user-profile-dialog.component';
|
||||||
import { SetDefaultAdminDialogComponent } from './dialogs/set-default-admin-dialog/set-default-admin-dialog.component';
|
import { SetDefaultAdminDialogComponent } from './dialogs/set-default-admin-dialog/set-default-admin-dialog.component';
|
||||||
@@ -42,8 +41,6 @@ export class AppComponent implements OnInit {
|
|||||||
allowThemeChange = null;
|
allowThemeChange = null;
|
||||||
allowSubscriptions = false;
|
allowSubscriptions = false;
|
||||||
enableDownloadsManager = false;
|
enableDownloadsManager = false;
|
||||||
// defaults to true to prevent attack
|
|
||||||
settingsPinRequired = true;
|
|
||||||
|
|
||||||
@ViewChild('sidenav') sidenav: MatSidenav;
|
@ViewChild('sidenav') sidenav: MatSidenav;
|
||||||
@ViewChild('hamburgerMenu', { read: ElementRef }) hamburgerMenuButton: ElementRef;
|
@ViewChild('hamburgerMenu', { read: ElementRef }) hamburgerMenuButton: ElementRef;
|
||||||
@@ -79,7 +76,6 @@ export class AppComponent implements OnInit {
|
|||||||
loadConfig() {
|
loadConfig() {
|
||||||
// loading config
|
// loading config
|
||||||
this.topBarTitle = this.postsService.config['Extra']['title_top'];
|
this.topBarTitle = this.postsService.config['Extra']['title_top'];
|
||||||
this.settingsPinRequired = this.postsService.config['Extra']['settings_pin_required'];
|
|
||||||
const themingExists = this.postsService.config['Themes'];
|
const themingExists = this.postsService.config['Themes'];
|
||||||
this.defaultTheme = themingExists ? this.postsService.config['Themes']['default_theme'] : 'default';
|
this.defaultTheme = themingExists ? this.postsService.config['Themes']['default_theme'] : 'default';
|
||||||
this.allowThemeChange = themingExists ? this.postsService.config['Themes']['allow_theme_change'] : true;
|
this.allowThemeChange = themingExists ? this.postsService.config['Themes']['allow_theme_change'] : true;
|
||||||
@@ -175,31 +171,11 @@ onSetTheme(theme, old_theme) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
openSettingsDialog() {
|
openSettingsDialog() {
|
||||||
if (this.settingsPinRequired) {
|
|
||||||
this.openPinDialog();
|
|
||||||
} else {
|
|
||||||
this.actuallyOpenSettingsDialog();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
actuallyOpenSettingsDialog() {
|
|
||||||
const dialogRef = this.dialog.open(SettingsComponent, {
|
const dialogRef = this.dialog.open(SettingsComponent, {
|
||||||
width: '80vw'
|
width: '80vw'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
openPinDialog() {
|
|
||||||
const dialogRef = this.dialog.open(CheckOrSetPinDialogComponent, {
|
|
||||||
});
|
|
||||||
|
|
||||||
dialogRef.afterClosed().subscribe(res => {
|
|
||||||
if (res) {
|
|
||||||
this.actuallyOpenSettingsDialog();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
openAboutDialog() {
|
openAboutDialog() {
|
||||||
const dialogRef = this.dialog.open(AboutDialogComponent, {
|
const dialogRef = this.dialog.open(AboutDialogComponent, {
|
||||||
width: '80vw'
|
width: '80vw'
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ import { SubscriptionComponent } from './subscription//subscription/subscription
|
|||||||
import { SubscriptionFileCardComponent } from './subscription/subscription-file-card/subscription-file-card.component';
|
import { SubscriptionFileCardComponent } from './subscription/subscription-file-card/subscription-file-card.component';
|
||||||
import { SubscriptionInfoDialogComponent } from './dialogs/subscription-info-dialog/subscription-info-dialog.component';
|
import { SubscriptionInfoDialogComponent } from './dialogs/subscription-info-dialog/subscription-info-dialog.component';
|
||||||
import { SettingsComponent } from './settings/settings.component';
|
import { SettingsComponent } from './settings/settings.component';
|
||||||
import { CheckOrSetPinDialogComponent } from './dialogs/check-or-set-pin-dialog/check-or-set-pin-dialog.component';
|
|
||||||
import { MatChipsModule } from '@angular/material/chips';
|
import { MatChipsModule } from '@angular/material/chips';
|
||||||
import { NgxFileDropModule } from 'ngx-file-drop';
|
import { NgxFileDropModule } from 'ngx-file-drop';
|
||||||
|
|
||||||
@@ -96,7 +95,6 @@ export function isVisible({ event, element, scrollContainer, offset }: IsVisible
|
|||||||
SubscriptionFileCardComponent,
|
SubscriptionFileCardComponent,
|
||||||
SubscriptionInfoDialogComponent,
|
SubscriptionInfoDialogComponent,
|
||||||
SettingsComponent,
|
SettingsComponent,
|
||||||
CheckOrSetPinDialogComponent,
|
|
||||||
AboutDialogComponent,
|
AboutDialogComponent,
|
||||||
VideoInfoDialogComponent,
|
VideoInfoDialogComponent,
|
||||||
ArgModifierDialogComponent,
|
ArgModifierDialogComponent,
|
||||||
@@ -169,8 +167,7 @@ export function isVisible({ event, element, scrollContainer, offset }: IsVisible
|
|||||||
CreatePlaylistComponent,
|
CreatePlaylistComponent,
|
||||||
SubscribeDialogComponent,
|
SubscribeDialogComponent,
|
||||||
SubscriptionInfoDialogComponent,
|
SubscriptionInfoDialogComponent,
|
||||||
SettingsComponent,
|
SettingsComponent
|
||||||
CheckOrSetPinDialogComponent
|
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
PostsService
|
PostsService
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
<h4 *ngIf="pinSetChecked" mat-dialog-title>{{dialog_title}}</h4>
|
|
||||||
|
|
||||||
<mat-dialog-content>
|
|
||||||
<div style="position: relative">
|
|
||||||
<div *ngIf="pinSetChecked">
|
|
||||||
<mat-form-field color="accent">
|
|
||||||
<input type="password" (keyup.enter)="doAction()" matInput [(ngModel)]="input" [placeholder]="input_placeholder">
|
|
||||||
</mat-form-field>
|
|
||||||
</div>
|
|
||||||
<div class="spinner-div" *ngIf="!pinSetChecked">
|
|
||||||
<mat-spinner [diameter]="25"></mat-spinner>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</mat-dialog-content>
|
|
||||||
|
|
||||||
<mat-dialog-actions>
|
|
||||||
<button [disabled]="input.length === 0" color="accent" style="margin-bottom: 12px;" (click)="doAction()" mat-raised-button>{{button_label}}</button>
|
|
||||||
</mat-dialog-actions>
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
.spinner-div {
|
|
||||||
position: absolute;
|
|
||||||
margin: 0 auto;
|
|
||||||
top: 30%;
|
|
||||||
left: 42%;
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { CheckOrSetPinDialogComponent } from './check-or-set-pin-dialog.component';
|
|
||||||
|
|
||||||
describe('CheckOrSetPinDialogComponent', () => {
|
|
||||||
let component: CheckOrSetPinDialogComponent;
|
|
||||||
let fixture: ComponentFixture<CheckOrSetPinDialogComponent>;
|
|
||||||
|
|
||||||
beforeEach(async(() => {
|
|
||||||
TestBed.configureTestingModule({
|
|
||||||
declarations: [ CheckOrSetPinDialogComponent ]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
}));
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(CheckOrSetPinDialogComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,96 +0,0 @@
|
|||||||
import { Component, OnInit, Inject } from '@angular/core';
|
|
||||||
import { PostsService } from 'app/posts.services';
|
|
||||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
|
||||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-check-or-set-pin-dialog',
|
|
||||||
templateUrl: './check-or-set-pin-dialog.component.html',
|
|
||||||
styleUrls: ['./check-or-set-pin-dialog.component.scss']
|
|
||||||
})
|
|
||||||
export class CheckOrSetPinDialogComponent implements OnInit {
|
|
||||||
|
|
||||||
pinSetChecked = false;
|
|
||||||
pinSet = true;
|
|
||||||
resetMode = false;
|
|
||||||
dialog_title = '';
|
|
||||||
input_placeholder = null;
|
|
||||||
input = '';
|
|
||||||
button_label = '';
|
|
||||||
|
|
||||||
constructor(private postsService: PostsService, @Inject(MAT_DIALOG_DATA) public data: any,
|
|
||||||
public dialogRef: MatDialogRef<CheckOrSetPinDialogComponent>, private snackBar: MatSnackBar) { }
|
|
||||||
|
|
||||||
ngOnInit() {
|
|
||||||
if (this.data) {
|
|
||||||
this.resetMode = this.data.resetMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.resetMode) {
|
|
||||||
this.pinSetChecked = true;
|
|
||||||
this.notSetLogic();
|
|
||||||
} else {
|
|
||||||
this.isPinSet();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
isPinSet() {
|
|
||||||
this.postsService.isPinSet().subscribe(res => {
|
|
||||||
this.pinSetChecked = true;
|
|
||||||
if (res['is_set']) {
|
|
||||||
this.isSetLogic();
|
|
||||||
} else {
|
|
||||||
this.notSetLogic();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
isSetLogic() {
|
|
||||||
this.pinSet = true;
|
|
||||||
this.dialog_title = 'Pin Required';
|
|
||||||
this.input_placeholder = 'Pin';
|
|
||||||
this.button_label = 'Submit'
|
|
||||||
}
|
|
||||||
|
|
||||||
notSetLogic() {
|
|
||||||
this.pinSet = false;
|
|
||||||
this.dialog_title = 'Set your pin';
|
|
||||||
this.input_placeholder = 'New pin';
|
|
||||||
this.button_label = 'Set Pin'
|
|
||||||
}
|
|
||||||
|
|
||||||
doAction() {
|
|
||||||
// pin set must have been checked, and input must not be empty
|
|
||||||
if (!this.pinSetChecked || this.input.length === 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.pinSet) {
|
|
||||||
this.postsService.checkPin(this.input).subscribe(res => {
|
|
||||||
if (res['success']) {
|
|
||||||
this.dialogRef.close(true);
|
|
||||||
} else {
|
|
||||||
this.dialogRef.close(false);
|
|
||||||
this.openSnackBar('Pin is incorrect!');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.postsService.setPin(this.input).subscribe(res => {
|
|
||||||
if (res['success']) {
|
|
||||||
this.dialogRef.close(true);
|
|
||||||
this.openSnackBar('Pin successfully set!');
|
|
||||||
} else {
|
|
||||||
this.dialogRef.close(false);
|
|
||||||
this.openSnackBar('Failed to set pin!');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public openSnackBar(message: string, action: string = '') {
|
|
||||||
this.snackBar.open(message, action, {
|
|
||||||
duration: 2000,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -242,18 +242,6 @@ export class PostsService implements CanActivate {
|
|||||||
return this.http.post(this.path + 'clearAllLogs', {}, this.httpOptions);
|
return this.http.post(this.path + 'clearAllLogs', {}, this.httpOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
isPinSet() {
|
|
||||||
return this.http.post(this.path + 'isPinSet', {}, this.httpOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
setPin(unhashed_pin) {
|
|
||||||
return this.http.post(this.path + 'setPin', {pin: unhashed_pin}, this.httpOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
checkPin(unhashed_pin) {
|
|
||||||
return this.http.post(this.path + 'checkPin', {input_pin: unhashed_pin}, this.httpOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
generateNewAPIKey() {
|
generateNewAPIKey() {
|
||||||
return this.http.post(this.path + 'generateNewAPIKey', {}, this.httpOptions);
|
return this.http.post(this.path + 'generateNewAPIKey', {}, this.httpOptions);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -186,10 +186,6 @@
|
|||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<mat-checkbox color="accent" [(ngModel)]="new_config['Extra']['allow_multi_download_mode']"><ng-container i18n="Allow multi-download mode setting">Allow multi-download mode</ng-container></mat-checkbox>
|
<mat-checkbox color="accent" [(ngModel)]="new_config['Extra']['allow_multi_download_mode']"><ng-container i18n="Allow multi-download mode setting">Allow multi-download mode</ng-container></mat-checkbox>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12">
|
|
||||||
<mat-checkbox [disabled]="new_config['Advanced']['multi_user_mode']" color="accent" [(ngModel)]="new_config['Extra']['settings_pin_required']"><ng-container i18n="Require pin for settings setting">Require pin for settings</ng-container></mat-checkbox>
|
|
||||||
<button style="margin-left: 15px; margin-bottom: 10px;" mat-stroked-button (click)="setNewPin()" [disabled]="!new_config['Extra']['settings_pin_required']"><ng-container i18n="Set new pin button">Set New Pin</ng-container></button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<mat-divider></mat-divider>
|
<mat-divider></mat-divider>
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { PostsService } from 'app/posts.services';
|
import { PostsService } from 'app/posts.services';
|
||||||
import { CheckOrSetPinDialogComponent } from 'app/dialogs/check-or-set-pin-dialog/check-or-set-pin-dialog.component';
|
|
||||||
import { isoLangs } from './locales_list';
|
import { isoLangs } from './locales_list';
|
||||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||||
import {DomSanitizer} from '@angular/platform-browser';
|
import {DomSanitizer} from '@angular/platform-browser';
|
||||||
@@ -77,14 +76,6 @@ export class SettingsComponent implements OnInit {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
setNewPin() {
|
|
||||||
const dialogRef = this.dialog.open(CheckOrSetPinDialogComponent, {
|
|
||||||
data: {
|
|
||||||
resetMode: true
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
generateAPIKey() {
|
generateAPIKey() {
|
||||||
this.postsService.generateNewAPIKey().subscribe(res => {
|
this.postsService.generateNewAPIKey().subscribe(res => {
|
||||||
if (res['new_api_key']) {
|
if (res['new_api_key']) {
|
||||||
|
|||||||
Reference in New Issue
Block a user