fix(web): remove checking for MFA permissions as all users are permitted to MFA
This commit is contained in:
@@ -1035,10 +1035,6 @@ export class SNApplication implements ApplicationInterface, AppGroupManagedAppli
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public isMfaFeatureAvailable(): boolean {
|
|
||||||
return this.mfaService.isMfaFeatureAvailable()
|
|
||||||
}
|
|
||||||
|
|
||||||
public async isMfaActivated(): Promise<boolean> {
|
public async isMfaActivated(): Promise<boolean> {
|
||||||
return this.mfaService.isMfaActivated()
|
return this.mfaService.isMfaActivated()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import { SettingName } from '@standardnotes/settings'
|
|||||||
import { SNSettingsService } from '../Settings'
|
import { SNSettingsService } from '../Settings'
|
||||||
import { PureCryptoInterface } from '@standardnotes/sncrypto-common'
|
import { PureCryptoInterface } from '@standardnotes/sncrypto-common'
|
||||||
import { SNFeaturesService } from '../Features/FeaturesService'
|
import { SNFeaturesService } from '../Features/FeaturesService'
|
||||||
import { FeatureIdentifier } from '@standardnotes/features'
|
|
||||||
import { AbstractService, InternalEventBusInterface, SignInStrings } from '@standardnotes/services'
|
import { AbstractService, InternalEventBusInterface, SignInStrings } from '@standardnotes/services'
|
||||||
|
|
||||||
export class SNMfaService extends AbstractService {
|
export class SNMfaService extends AbstractService {
|
||||||
@@ -47,17 +46,6 @@ export class SNMfaService extends AbstractService {
|
|||||||
return await this.settingsService.deleteSetting(SettingName.MfaSecret)
|
return await this.settingsService.deleteSetting(SettingName.MfaSecret)
|
||||||
}
|
}
|
||||||
|
|
||||||
isMfaFeatureAvailable(): boolean {
|
|
||||||
const feature = this.featuresService.getUserFeature(FeatureIdentifier.TwoFactorAuth)
|
|
||||||
|
|
||||||
// If the feature is not present in the collection, we don't want to block it
|
|
||||||
if (feature == undefined) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return feature.no_expire === true || (feature.expires_at ?? 0) > Date.now()
|
|
||||||
}
|
|
||||||
|
|
||||||
override deinit(): void {
|
override deinit(): void {
|
||||||
;(this.settingsService as unknown) = undefined
|
;(this.settingsService as unknown) = undefined
|
||||||
;(this.crypto as unknown) = undefined
|
;(this.crypto as unknown) = undefined
|
||||||
|
|||||||
@@ -81,10 +81,6 @@ export class TwoFactorAuth {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.isMfaFeatureAvailable()) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
this.mfaProvider
|
this.mfaProvider
|
||||||
.isMfaActivated()
|
.isMfaActivated()
|
||||||
.then(
|
.then(
|
||||||
@@ -110,10 +106,6 @@ export class TwoFactorAuth {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.isMfaFeatureAvailable()) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this._status === 'two-factor-disabled') {
|
if (this._status === 'two-factor-disabled') {
|
||||||
return this.startActivation()
|
return this.startActivation()
|
||||||
}
|
}
|
||||||
@@ -130,8 +122,4 @@ export class TwoFactorAuth {
|
|||||||
get status(): TwoFactorStatus | 'fetching' {
|
get status(): TwoFactorStatus | 'fetching' {
|
||||||
return this._status
|
return this._status
|
||||||
}
|
}
|
||||||
|
|
||||||
isMfaFeatureAvailable(): boolean {
|
|
||||||
return this.mfaProvider.isMfaFeatureAvailable()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,17 +11,7 @@ const TwoFactorDescription: FunctionComponent<Props> = ({ auth }) => {
|
|||||||
if (!auth.isLoggedIn()) {
|
if (!auth.isLoggedIn()) {
|
||||||
return <Text>Sign in or register for an account to configure 2FA.</Text>
|
return <Text>Sign in or register for an account to configure 2FA.</Text>
|
||||||
}
|
}
|
||||||
if (!auth.isMfaFeatureAvailable()) {
|
|
||||||
return (
|
|
||||||
<Text>
|
|
||||||
A paid subscription plan is required to enable 2FA.{' '}
|
|
||||||
<a target="_blank" href="https://standardnotes.com/features">
|
|
||||||
Learn more
|
|
||||||
</a>
|
|
||||||
.
|
|
||||||
</Text>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return <Text>An extra layer of security when logging in to your account.</Text>
|
return <Text>An extra layer of security when logging in to your account.</Text>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ type Props = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const TwoFactorSwitch: FunctionComponent<Props> = ({ auth }) => {
|
const TwoFactorSwitch: FunctionComponent<Props> = ({ auth }) => {
|
||||||
if (!(auth.isLoggedIn() && auth.isMfaFeatureAvailable())) {
|
if (!auth.isLoggedIn()) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,9 +11,7 @@ const TwoFactorTitle: FunctionComponent<Props> = ({ auth }) => {
|
|||||||
if (!auth.isLoggedIn()) {
|
if (!auth.isLoggedIn()) {
|
||||||
return <Title>Two-factor authentication not available</Title>
|
return <Title>Two-factor authentication not available</Title>
|
||||||
}
|
}
|
||||||
if (!auth.isMfaFeatureAvailable()) {
|
|
||||||
return <Title>Two-factor authentication not available</Title>
|
|
||||||
}
|
|
||||||
return <Title>Two-factor authentication</Title>
|
return <Title>Two-factor authentication</Title>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,4 @@ export interface MfaProvider {
|
|||||||
enableMfa(secret: string, otpToken: string): Promise<void>
|
enableMfa(secret: string, otpToken: string): Promise<void>
|
||||||
|
|
||||||
disableMfa(): Promise<void>
|
disableMfa(): Promise<void>
|
||||||
|
|
||||||
isMfaFeatureAvailable(): boolean
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user