const Entry = require(`./object.JS`); const Hash = require(`../../utilities/hash.JS`); class User extends Entry { /* Default properties: name ID activated = false passcode */ #login = false; constructor(PROPERTIES) { super(PROPERTIES); this.authenticate(); }; /* Authenticate the user @param {STRING} INPUT the passcode passed @return {BOOLEAN} the user authentication state */ authenticate(INPUT) { // Reset the login state. if (this.#login) {this.#login = false;}; if ((this.passcode) ? (INPUT && this.passcode == INPUT) : true) { this.#login = true; } return (this.#login); } /* Generate a schema for MongoDB. @return {OBJECT} the schema */ static generateTemplate() { let SCHEMA = { "name": {"type": String, "required": true, "unique": true, "dropDups": true}, "ID": {"type": String, "required": true, "unique": true, "dropDups": true}, "activated": {"type": Boolean}, "passcode": {"type": String} }; return (SCHEMA); } } module.exports = User;