Skip to content

Commit

Permalink
🐛 (#69) Keep _users docs not managed by couchAuth
Browse files Browse the repository at this point in the history
Log a warning + reject as invalid session, but do not delete the doc
  • Loading branch information
fynnlyte committed Mar 22, 2023
1 parent 9d703fe commit 886f449
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1305,6 +1305,12 @@ export class User {
public async confirmSession(key: string, password: string) {
try {
const doc = await this.dbAuth.retrieveKey(key);
if (!doc.provider || !doc.expires) {
const msg = `_users doc ${key} is not managed by CouchAuth`;
console.warn(msg);
throw msg;
}

if (doc.expires > Date.now()) {
doc._id = doc.user_id;
delete doc.user_id;
Expand Down

0 comments on commit 886f449

Please sign in to comment.