mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
feat(admin): provide reset cron button
This commit is contained in:
@@ -36,6 +36,12 @@
|
|||||||
("auth.timestamps.loggedin" and "lastCron" dates are different).
|
("auth.timestamps.loggedin" and "lastCron" dates are different).
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
<button
|
||||||
|
class="btn btn-primary"
|
||||||
|
@click="resetCron()"
|
||||||
|
>
|
||||||
|
Reset Cron to Yesterday
|
||||||
|
</button>
|
||||||
<div class="subsection-start">
|
<div class="subsection-start">
|
||||||
Time zone:
|
Time zone:
|
||||||
<strong>{{ hero.preferences.timezoneOffset | formatTimeZone }}</strong>
|
<strong>{{ hero.preferences.timezoneOffset | formatTimeZone }}</strong>
|
||||||
@@ -218,6 +224,10 @@ export default {
|
|||||||
await this.saveHero({ hero: this.hero, msg: 'API Token' });
|
await this.saveHero({ hero: this.hero, msg: 'API Token' });
|
||||||
this.tokenModified = true;
|
this.tokenModified = true;
|
||||||
},
|
},
|
||||||
|
resetCron () {
|
||||||
|
this.hero.resetCron = true;
|
||||||
|
this.saveHero({ hero: this.hero, msg: 'Last Cron', clearData: true });
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -331,6 +331,13 @@ api.updateHero = {
|
|||||||
hero.apiToken = common.uuid();
|
hero.apiToken = common.uuid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (updateData.resetCron) {
|
||||||
|
// Set last cron to yesterday. Quick approach so we don't need moment() for one line
|
||||||
|
const yesterday = new Date(new Date().setDate(new Date().getDate() - 1));
|
||||||
|
hero.lastCron = yesterday;
|
||||||
|
hero.auth.timestamps.loggedin = yesterday; // so admin panel doesn't gripe about mismatch
|
||||||
|
}
|
||||||
|
|
||||||
const savedHero = await hero.save();
|
const savedHero = await hero.save();
|
||||||
const heroJSON = savedHero.toJSON();
|
const heroJSON = savedHero.toJSON();
|
||||||
heroJSON.secret = savedHero.getSecretData();
|
heroJSON.secret = savedHero.getSecretData();
|
||||||
|
|||||||
Reference in New Issue
Block a user