Browse Source

Rename Google OAuth and Security Token control variables

pull/5915/head
Germán Martín 2 months ago
committed by Thomas Kaul
parent
commit
4bf4e6d96b
  1. 9
      .env.example
  2. 8
      apps/api/src/app/info/info.service.ts
  3. 3
      apps/api/src/services/configuration/configuration.service.ts
  4. 3
      apps/api/src/services/interfaces/environment.interface.ts
  5. 15
      apps/client/src/app/components/header/header.component.ts
  6. 3
      apps/client/src/app/components/login-with-access-token-dialog/interfaces/interfaces.ts
  7. 75
      apps/client/src/app/components/login-with-access-token-dialog/login-with-access-token-dialog.html
  8. 12
      apps/client/src/app/pages/register/register-page.component.ts
  9. 22
      apps/client/src/app/pages/register/register-page.html
  10. 5
      libs/common/src/lib/permissions.ts

9
.env.example

@ -14,3 +14,12 @@ POSTGRES_PASSWORD=<INSERT_POSTGRES_PASSWORD>
ACCESS_TOKEN_SALT=<INSERT_RANDOM_STRING>
DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}?connect_timeout=300&sslmode=prefer
JWT_SECRET_KEY=<INSERT_RANDOM_STRING>
# AUTHENTICATION
# Enable authentication with Google OAuth (default: false)
# ENABLE_FEATURE_AUTH_GOOGLE=true
# GOOGLE_CLIENT_ID=<INSERT_GOOGLE_CLIENT_ID>
# GOOGLE_SECRET=<INSERT_GOOGLE_SECRET>
# Enable authentication with Security Token (default: true)
# ENABLE_FEATURE_AUTH_TOKEN=true

8
apps/api/src/app/info/info.service.ts

@ -70,8 +70,12 @@ export class InfoService {
);
}
if (this.configurationService.get('ENABLE_FEATURE_SOCIAL_LOGIN')) {
globalPermissions.push(permissions.enableSocialLogin);
if (this.configurationService.get('ENABLE_FEATURE_AUTH_GOOGLE')) {
globalPermissions.push(permissions.enableAuthGoogle);
}
if (this.configurationService.get('ENABLE_FEATURE_AUTH_TOKEN')) {
globalPermissions.push(permissions.enableAuthToken);
}
if (this.configurationService.get('ENABLE_FEATURE_STATISTICS')) {

3
apps/api/src/services/configuration/configuration.service.ts

@ -42,7 +42,8 @@ export class ConfigurationService {
}),
ENABLE_FEATURE_FEAR_AND_GREED_INDEX: bool({ default: false }),
ENABLE_FEATURE_READ_ONLY_MODE: bool({ default: false }),
ENABLE_FEATURE_SOCIAL_LOGIN: bool({ default: false }),
ENABLE_FEATURE_AUTH_GOOGLE: bool({ default: false }),
ENABLE_FEATURE_AUTH_TOKEN: bool({ default: true }),
ENABLE_FEATURE_STATISTICS: bool({ default: false }),
ENABLE_FEATURE_SUBSCRIPTION: bool({ default: false }),
ENABLE_FEATURE_SYSTEM_MESSAGE: bool({ default: false }),

3
apps/api/src/services/interfaces/environment.interface.ts

@ -18,7 +18,8 @@ export interface Environment extends CleanedEnvAccessors {
DATA_SOURCES_GHOSTFOLIO_DATA_PROVIDER: string[];
ENABLE_FEATURE_FEAR_AND_GREED_INDEX: boolean;
ENABLE_FEATURE_READ_ONLY_MODE: boolean;
ENABLE_FEATURE_SOCIAL_LOGIN: boolean;
ENABLE_FEATURE_AUTH_GOOGLE: boolean;
ENABLE_FEATURE_AUTH_TOKEN: boolean;
ENABLE_FEATURE_STATISTICS: boolean;
ENABLE_FEATURE_SUBSCRIPTION: boolean;
ENABLE_FEATURE_SYSTEM_MESSAGE: boolean;

15
apps/client/src/app/components/header/header.component.ts

@ -105,7 +105,8 @@ export class GfHeaderComponent implements OnChanges {
public hasFilters: boolean;
public hasImpersonationId: boolean;
public hasPermissionForSocialLogin: boolean;
public hasPermissionForAuthGoogle: boolean;
public hasPermissionForAuthToken: boolean;
public hasPermissionForSubscription: boolean;
public hasPermissionToAccessAdminControl: boolean;
public hasPermissionToAccessAssistant: boolean;
@ -165,9 +166,14 @@ export class GfHeaderComponent implements OnChanges {
public ngOnChanges() {
this.hasFilters = this.userService.hasFilters();
this.hasPermissionForSocialLogin = hasPermission(
this.hasPermissionForAuthGoogle = hasPermission(
this.info?.globalPermissions,
permissions.enableSocialLogin
permissions.enableAuthGoogle
);
this.hasPermissionForAuthToken = hasPermission(
this.info?.globalPermissions,
permissions.enableAuthToken
);
this.hasPermissionForSubscription = hasPermission(
@ -280,7 +286,8 @@ export class GfHeaderComponent implements OnChanges {
autoFocus: false,
data: {
accessToken: '',
hasPermissionToUseSocialLogin: this.hasPermissionForSocialLogin,
hasPermissionToUseAuthGoogle: this.hasPermissionForAuthGoogle,
hasPermissionToUseAuthToken: this.hasPermissionForAuthToken,
title: $localize`Sign in`
},
width: '30rem'

3
apps/client/src/app/components/login-with-access-token-dialog/interfaces/interfaces.ts

@ -1,5 +1,6 @@
export interface LoginWithAccessTokenDialogParams {
accessToken: string;
hasPermissionToUseSocialLogin: boolean;
hasPermissionToUseAuthGoogle: boolean;
hasPermissionToUseAuthToken: boolean;
title: string;
}

75
apps/client/src/app/components/login-with-access-token-dialog/login-with-access-token-dialog.html

@ -3,28 +3,35 @@
<div class="py-3" mat-dialog-content>
<div class="align-items-center d-flex flex-column">
<form class="w-100">
<mat-form-field appearance="outline" class="without-hint w-100">
<mat-label i18n>Security Token</mat-label>
<input
matInput
[formControl]="accessTokenFormControl"
[type]="isAccessTokenHidden ? 'password' : 'text'"
(keydown.enter)="onLoginWithAccessToken(); $event.preventDefault()"
/>
<button
mat-button
matSuffix
type="button"
(click)="isAccessTokenHidden = !isAccessTokenHidden"
>
<ion-icon
[name]="isAccessTokenHidden ? 'eye-outline' : 'eye-off-outline'"
@if (data.hasPermissionToUseAuthToken) {
<mat-form-field appearance="outline" class="without-hint w-100">
<mat-label i18n>Security Token</mat-label>
<input
matInput
[formControl]="accessTokenFormControl"
[type]="isAccessTokenHidden ? 'password' : 'text'"
(keydown.enter)="onLoginWithAccessToken(); $event.preventDefault()"
/>
</button>
</mat-form-field>
<button
mat-button
matSuffix
type="button"
(click)="isAccessTokenHidden = !isAccessTokenHidden"
>
<ion-icon
[name]="isAccessTokenHidden ? 'eye-outline' : 'eye-off-outline'"
/>
</button>
</mat-form-field>
}
@if (data.hasPermissionToUseSocialLogin) {
@if (
data.hasPermissionToUseAuthGoogle && data.hasPermissionToUseAuthToken
) {
<div class="my-3 text-center text-muted" i18n>or</div>
}
@if (data.hasPermissionToUseAuthGoogle) {
<div class="d-flex flex-column">
<a
class="px-4 rounded-pill"
@ -44,20 +51,24 @@
<div mat-dialog-actions>
<div class="flex-grow-1">
<mat-checkbox color="primary" i18n (change)="onChangeStaySignedIn($event)"
>Stay signed in</mat-checkbox
>
@if (data.hasPermissionToUseAuthToken) {
<mat-checkbox color="primary" i18n (change)="onChangeStaySignedIn($event)"
>Stay signed in</mat-checkbox
>
}
</div>
<div>
<button
color="primary"
mat-flat-button
[disabled]="
!(accessTokenFormControl.dirty && accessTokenFormControl.valid)
"
(click)="onLoginWithAccessToken()"
>
<ng-container i18n>Sign in</ng-container>
</button>
@if (data.hasPermissionToUseAuthToken) {
<button
color="primary"
mat-flat-button
[disabled]="
!(accessTokenFormControl.dirty && accessTokenFormControl.valid)
"
(click)="onLoginWithAccessToken()"
>
<ng-container i18n>Sign in</ng-container>
</button>
}
</div>
</div>

12
apps/client/src/app/pages/register/register-page.component.ts

@ -30,7 +30,8 @@ import { GfUserAccountRegistrationDialogComponent } from './user-account-registr
})
export class GfRegisterPageComponent implements OnDestroy, OnInit {
public deviceType: string;
public hasPermissionForSocialLogin: boolean;
public hasPermissionForAuthGoogle: boolean;
public hasPermissionForAuthToken: boolean;
public hasPermissionForSubscription: boolean;
public hasPermissionToCreateUser: boolean;
public historicalDataItems: LineChartItem[];
@ -55,9 +56,14 @@ export class GfRegisterPageComponent implements OnDestroy, OnInit {
this.deviceType = this.deviceService.getDeviceInfo().deviceType;
this.hasPermissionForSocialLogin = hasPermission(
this.hasPermissionForAuthGoogle = hasPermission(
globalPermissions,
permissions.enableSocialLogin
permissions.enableAuthGoogle
);
this.hasPermissionForAuthToken = hasPermission(
globalPermissions,
permissions.enableAuthToken
);
this.hasPermissionForSubscription = hasPermission(

22
apps/client/src/app/pages/register/register-page.html

@ -18,16 +18,20 @@
<div class="button-container row">
<div class="align-items-center col d-flex justify-content-center">
<div class="py-5 text-center">
<button
class="d-inline-block"
color="primary"
mat-flat-button
(click)="openShowAccessTokenDialog()"
>
<ng-container i18n>Create Account</ng-container>
</button>
@if (hasPermissionForSocialLogin) {
@if (hasPermissionForAuthToken) {
<button
class="d-inline-block"
color="primary"
mat-flat-button
(click)="openShowAccessTokenDialog()"
>
<ng-container i18n>Create Account</ng-container>
</button>
}
@if (hasPermissionForAuthGoogle && hasPermissionForAuthToken) {
<div class="my-3 text-muted" i18n>or</div>
}
@if (hasPermissionForAuthGoogle) {
<a
class="px-4 rounded-pill w-100"
href="../api/v1/auth/google"

5
libs/common/src/lib/permissions.ts

@ -32,7 +32,8 @@ export const permissions = {
enableFearAndGreedIndex: 'enableFearAndGreedIndex',
enableImport: 'enableImport',
enableBlog: 'enableBlog',
enableSocialLogin: 'enableSocialLogin',
enableAuthGoogle: 'enableAuthGoogle',
enableAuthToken: 'enableAuthToken',
enableStatistics: 'enableStatistics',
enableSubscription: 'enableSubscription',
enableSubscriptionInterstitial: 'enableSubscriptionInterstitial',
@ -157,7 +158,7 @@ export function filterGlobalPermissions(
if (aUtmSource === 'ios') {
return globalPermissions.filter((permission) => {
return (
permission !== permissions.enableSocialLogin &&
permission !== permissions.enableAuthGoogle &&
permission !== permissions.enableSubscription
);
});

Loading…
Cancel
Save