-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d6e3994
commit 432bf93
Showing
29 changed files
with
1,325 additions
and
523 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { | ||
EmailAuthProvider, | ||
reauthenticateWithCredential, | ||
updateEmail, | ||
} from "firebase/auth"; | ||
import Auth from "../classes/auth"; | ||
|
||
const changeEmail = async ( | ||
password: string, | ||
newEmail: string | ||
): Promise<void> => { | ||
const logInfo = (await import("../../impower-logger/utils/logInfo")).default; | ||
logInfo("Auth", "UPDATING EMAIL"); | ||
const user = Auth.instance.internal.currentUser; | ||
try { | ||
await updateEmail(user, newEmail); | ||
} catch { | ||
const credential = EmailAuthProvider.credential(user.email, password); | ||
await reauthenticateWithCredential(user, credential); | ||
await updateEmail(user, newEmail); | ||
} | ||
}; | ||
|
||
export default changeEmail; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { | ||
EmailAuthProvider, | ||
reauthenticateWithCredential, | ||
updatePassword, | ||
} from "firebase/auth"; | ||
import Auth from "../classes/auth"; | ||
|
||
const changePassword = async ( | ||
oldPassword: string, | ||
newPassword: string | ||
): Promise<void> => { | ||
const logInfo = (await import("../../impower-logger/utils/logInfo")).default; | ||
logInfo("Auth", "UPDATING PASSWORD"); | ||
const user = Auth.instance.internal.currentUser; | ||
try { | ||
await updatePassword(user, newPassword); | ||
} catch { | ||
const credential = EmailAuthProvider.credential(user.email, oldPassword); | ||
await reauthenticateWithCredential(user, credential); | ||
await updatePassword(user, newPassword); | ||
} | ||
}; | ||
|
||
export default changePassword; |
35 changes: 35 additions & 0 deletions
35
client/modules/impower-data-store/classes/inspectors/settingsDocumentInspector.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { SettingsDocument } from "../.."; | ||
import { Inspector } from "../../../impower-core"; | ||
import createSettingsDocument from "../../utils/createSettingsDocument"; | ||
|
||
export class SettingsDocumentInspector implements Inspector<SettingsDocument> { | ||
private static _instance: SettingsDocumentInspector; | ||
|
||
public static get instance(): SettingsDocumentInspector { | ||
if (!this._instance) { | ||
this._instance = new SettingsDocumentInspector(); | ||
} | ||
return this._instance; | ||
} | ||
|
||
createData(data?: Partial<SettingsDocument>): SettingsDocument { | ||
return createSettingsDocument(data); | ||
} | ||
|
||
isPropertyDisabled(propertyPath: string, data: SettingsDocument): boolean { | ||
if (propertyPath === "nsfwBlurred") { | ||
return !data.nsfwVisible; | ||
} | ||
return undefined; | ||
} | ||
|
||
getPropertyLabel(propertyPath: string, _data: SettingsDocument): string { | ||
if (propertyPath === "nsfwVisible") { | ||
return "Show NSFW content (I'm over 18)"; | ||
} | ||
if (propertyPath === "nsfwBlurred") { | ||
return "Blur NSFW images"; | ||
} | ||
return undefined; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
432bf93
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: