mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-09-29 13:41:45 +02:00
fix: encrypt stored GitHub credentials (#797)
This commit is contained in:
+1
-16
@@ -70,23 +70,8 @@ export default class Repository {
|
||||
this.owner.model.isNew = false;
|
||||
}
|
||||
|
||||
private checkedToken: boolean = false;
|
||||
|
||||
async getToken() {
|
||||
if (this.checkedToken) return this._model.source.accessToken as string;
|
||||
const originalToken = this._model.source.accessToken;
|
||||
const token = await getToken(this);
|
||||
if (originalToken != token) {
|
||||
this._model.source.accessToken = token;
|
||||
if (isConnected) {
|
||||
await AnonymizedRepositoryModel.updateOne(
|
||||
{ _id: this._model._id },
|
||||
{ $set: { "source.accessToken": token } }
|
||||
).exec();
|
||||
}
|
||||
}
|
||||
this.checkedToken = true;
|
||||
return token;
|
||||
return getToken(this);
|
||||
}
|
||||
|
||||
get source() {
|
||||
|
||||
Reference in New Issue
Block a user