mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-05-22 05:38:46 +00:00
feat(admin): provide reset cron button
This commit is contained in:
parent
bc5813fd10
commit
09d6dae75c
2 changed files with 17 additions and 0 deletions
|
|
@ -36,6 +36,12 @@
|
|||
("auth.timestamps.loggedin" and "lastCron" dates are different).
|
||||
</span>
|
||||
</div>
|
||||
<button
|
||||
class="btn btn-primary"
|
||||
@click="resetCron()"
|
||||
>
|
||||
Reset Cron to Yesterday
|
||||
</button>
|
||||
<div class="subsection-start">
|
||||
Time zone:
|
||||
<strong>{{ hero.preferences.timezoneOffset | formatTimeZone }}</strong>
|
||||
|
|
@ -218,6 +224,10 @@ export default {
|
|||
await this.saveHero({ hero: this.hero, msg: 'API Token' });
|
||||
this.tokenModified = true;
|
||||
},
|
||||
resetCron () {
|
||||
this.hero.resetCron = true;
|
||||
this.saveHero({ hero: this.hero, msg: 'Last Cron', clearData: true });
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -331,6 +331,13 @@ api.updateHero = {
|
|||
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 heroJSON = savedHero.toJSON();
|
||||
heroJSON.secret = savedHero.getSecretData();
|
||||
|
|
|
|||
Loading…
Reference in a new issue