ActivityPub-federated video streaming platform using P2P directly in your web browser
Add ability to display email with auth plugin
Chocobozzz3b97d1afda3e
diff --git a/client/src/app/+my-account/my-account-settings/my-account-change-email/my-account-change-email.component.ts b/client/src/app/+my-account/my-account-settings/my-account-change-email/my-account-change-email.component.tsindex c2eaef3357..790ce8f38d 100644--- a/client/src/app/+my-account/my-account-settings/my-account-change-email/my-account-change-email.component.ts+++ b/client/src/app/+my-account/my-account-settings/my-account-change-email/my-account-change-email.component.ts@@ -1,4 +1,4 @@-import { NgClass, NgIf } from '@angular/common'+import { CommonModule, NgClass } from '@angular/common'import { Component, OnInit, inject } from '@angular/core'import { FormsModule, ReactiveFormsModule } from '@angular/forms'import { AuthService, ServerService, UserService } from '@app/core'@@ -16,7 +16,7 @@ import { InputTextComponent } from '../../../shared/shared-forms/input-text.compselector: 'my-account-change-email',templateUrl: './my-account-change-email.component.html',styleUrls: [ './my-account-change-email.component.scss' ],- imports: [ NgIf, FormsModule, ReactiveFormsModule, NgClass, InputTextComponent, AlertComponent ]+ imports: [ CommonModule, FormsModule, ReactiveFormsModule, NgClass, InputTextComponent, AlertComponent ]})export class MyAccountChangeEmailComponent extends FormReactive implements OnInit {protected formReactiveService = inject(FormReactiveService)diff --git a/client/src/app/+my-account/my-account-settings/my-account-email-preferences/my-account-email-preferences.component.html b/client/src/app/+my-account/my-account-settings/my-account-email-preferences/my-account-email-preferences.component.htmlindex 5eeaa117e3..a18d0c0459 100644--- a/client/src/app/+my-account/my-account-settings/my-account-email-preferences/my-account-email-preferences.component.html+++ b/client/src/app/+my-account/my-account-settings/my-account-email-preferences/my-account-email-preferences.component.html@@ -1,10 +1,11 @@<form (ngSubmit)="updateEmailPublic()" [formGroup]="form"><div class="form-group">- <my-peertube-checkbox- inputName="email-public" formControlName="email-public"- i18n-labelText labelText="Allow email to be publicly displayed"- >+ <my-peertube-checkbox inputName="email-public" formControlName="email-public">+ <ng-template ptTemplate="label">+ <ng-container i18n>Allow email <strong>{{ user().email }}</strong> to be publicly displayed</ng-container>+ </ng-template>+<ng-container ngProjectAs="description"><p class="mb-0">@if (user().emailVerified) {diff --git a/client/src/app/+my-account/my-account-settings/my-account-email-preferences/my-account-email-preferences.component.ts b/client/src/app/+my-account/my-account-settings/my-account-email-preferences/my-account-email-preferences.component.tsindex c2d03e3770..a3d731936c 100644--- a/client/src/app/+my-account/my-account-settings/my-account-email-preferences/my-account-email-preferences.component.ts+++ b/client/src/app/+my-account/my-account-settings/my-account-email-preferences/my-account-email-preferences.component.ts@@ -3,6 +3,7 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms'import { Notifier, UserService } from '@app/core'import { FormReactive } from '@app/shared/shared-forms/form-reactive'import { FormReactiveService } from '@app/shared/shared-forms/form-reactive.service'+import { PeerTubeTemplateDirective } from '@app/shared/shared-main/common/peertube-template.directive'import { User, UserUpdateMe } from '@peertube/peertube-models'import { PeertubeCheckboxComponent } from '../../../shared/shared-forms/peertube-checkbox.component'@@ -10,7 +11,7 @@ import { PeertubeCheckboxComponent } from '../../../shared/shared-forms/peertubeselector: 'my-account-email-preferences',templateUrl: './my-account-email-preferences.component.html',styleUrls: [ './my-account-email-preferences.component.scss' ],- imports: [ FormsModule, ReactiveFormsModule, PeertubeCheckboxComponent ]+ imports: [ FormsModule, ReactiveFormsModule, PeertubeCheckboxComponent, PeerTubeTemplateDirective ]})export class MyAccountEmailPreferencesComponent extends FormReactive implements OnInit {protected formReactiveService = inject(FormReactiveService)@@ -19,12 +20,16 @@ export class MyAccountEmailPreferencesComponent extends FormReactive implementsreadonly user = model<User>(undefined)+ checkboxLabel: string+ngOnInit () {this.buildForm({'email-public': null})this.form.patchValue({ 'email-public': this.user().emailPublic })++ this.checkboxLabel = $localize``}updateEmailPublic () {diff --git a/client/src/app/+my-account/my-account-settings/my-account-settings.component.html b/client/src/app/+my-account/my-account-settings/my-account-settings.component.htmlindex b604663b60..75f62af133 100644--- a/client/src/app/+my-account/my-account-settings/my-account-settings.component.html+++ b/client/src/app/+my-account/my-account-settings/my-account-settings.component.html@@ -84,7 +84,7 @@</div></div>-<div class="pt-two-cols mt-5" *ngIf="user.pluginAuth === null"> <!-- email grid -->+<div class="pt-two-cols mt-5"> <!-- email grid --><div class="title-col"><h2 i18n>EMAIL</h2></div>@@ -92,7 +92,9 @@<div class="content-col"><my-account-email-preferences class="d-block mb-5" [user]="user"></my-account-email-preferences>- <my-account-change-email></my-account-change-email>+ @if (user.pluginAuth === null) {+ <my-account-change-email></my-account-change-email>+ }</div></div>diff --git a/client/src/standalone/player/src/peertube-player.ts b/client/src/standalone/player/src/peertube-player.tsindex ae067bb0c0..7fdbc7803a 100644--- a/client/src/standalone/player/src/peertube-player.ts+++ b/client/src/standalone/player/src/peertube-player.ts@@ -250,7 +250,7 @@ export class PeerTubePlayer {this.player.on('network-info', (_: any, data: PlayerNetworkInfo) => {if (data.source !== 'p2p-media-loader' || isNaN(data.bandwidthEstimate)) return- saveAverageBandwidth(data.bandwidthEstimate)+ saveAverageBandwidth(Math.floor(data.bandwidthEstimate))})this.player.contextMenu(this.getContextMenuOptions())diff --git a/scripts/dev/client.sh b/scripts/dev/client.shindex e738238905..79ab78a15c 100755--- a/scripts/dev/client.sh+++ b/scripts/dev/client.sh@@ -12,7 +12,7 @@ fiembedCommand="cd client/src/standalone/player && npm run dev"clientCommand="cd client && NODE_OPTIONS=--max_old_space_size=8192 node_modules/.bin/ng serve --proxy-config proxy.config.json --hmr --configuration $clientConfiguration --host 0.0.0.0 --port 3000"-serverCommand="NODE_ENV=dev node dist/server"+serverCommand="ANGULAR_CLIENT_ENABLED=true NODE_ENV=dev node dist/server"if [ ! -z ${1+x} ] && [ "$1" = "--skip-server" ]; thennode_modules/.bin/concurrently -k \diff --git a/scripts/dev/index.sh b/scripts/dev/index.shindex 7e0332115a..304c5c52e8 100755--- a/scripts/dev/index.sh+++ b/scripts/dev/index.sh@@ -4,4 +4,4 @@ set -eunpm run concurrently -- -k \"sh scripts/dev/client.sh --skip-server ${1:-}" \- "sh scripts/dev/server.sh --skip-client"+ "ANGULAR_CLIENT_ENABLED=true sh scripts/dev/server.sh --skip-client"diff --git a/server/core/lib/auth/external-auth.ts b/server/core/lib/auth/external-auth.tsindex 35fecb860c..6b7b4a5b76 100644--- a/server/core/lib/auth/external-auth.ts+++ b/server/core/lib/auth/external-auth.ts@@ -19,10 +19,11 @@ import {} from '@server/types/plugins/register-server-auth.model.js'import { UserAdminFlag, UserRole } from '@peertube/peertube-models'import { BypassLogin } from './oauth-model.js'+import { isDevInstance } from '@peertube/peertube-node-utils'export type ExternalUser =- Pick<MUser, 'username' | 'email' | 'role' | 'adminFlags' | 'videoQuotaDaily' | 'videoQuota'> &- { displayName: string }+ & Pick<MUser, 'username' | 'email' | 'role' | 'adminFlags' | 'videoQuotaDaily' | 'videoQuota'>+ & { displayName: string }// Token is the key, expiration date is the valueconst authBypassTokens = new Map<string, {@@ -82,7 +83,13 @@ async function onExternalUserAuthenticated (options: {url.searchParams.set('username', user.username)res.redirect(url.href)} else {- res.redirect(`/login?externalAuthToken=${bypassToken}&username=${user.username}`)+ const query = `externalAuthToken=${bypassToken}&username=${user.username}`++ if (isDevInstance() && process.env.ANGULAR_CLIENT_ENABLED === 'true') {+ res.redirect(`http://localhost:3000/login?${query}`)+ } else {+ res.redirect(`/login?${query}`)+ }}}@@ -131,7 +138,10 @@ async function getBypassFromPasswordGrant (username: string, password: string):logger.debug('Using auth method %s of plugin %s to login %s with weight %d.',- authName, npmName, loginOptions.id, authOptions.getWeight()+ authName,+ npmName,+ loginOptions.id,+ authOptions.getWeight())try {@@ -142,7 +152,9 @@ async function getBypassFromPasswordGrant (username: string, password: string):logger.info('Login success with auth method %s of plugin %s for %s.',- authName, npmName, loginOptions.id+ authName,+ npmName,+ loginOptions.id)return {@@ -177,7 +189,9 @@ function getBypassFromExternalAuth (username: string, externalAuthToken: string)logger.info('Auth success with external auth method %s of plugin %s for %s.',- authName, npmName, user.email+ authName,+ npmName,+ user.email)return {