aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/models/Access.js
diff options
context:
space:
mode:
Diffstat (limited to 'models/Access.js')
-rw-r--r--models/Access.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/models/Access.js b/models/Access.js
index ba8097d..69b556a 100644
--- a/models/Access.js
+++ b/models/Access.js
@@ -31,6 +31,30 @@ var AccessSchema = new Schema({
// the four validations below only apply if you are signing up traditionally
+AccessSchema.methods = {
+
+ /**
+ * Generate random access token for Remember Me function
+ *
+ * @param {Number} length
+ * @return {String}
+ * @api public
+ */
+
+ generateRandomToken: function(length) {
+ if (typeof(length) === undefined) length = 16; // default length of token
+ var chars = '_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'
+ , token = '';
+ for (var i = 0; i < length; i++) {
+ var x = Math.floor(Math.random() * chars.length);
+ token += chars.charAt(x);
+ }
+ console.log('token ' + token);
+ return token;
+ }
+
+}
+
AccessSchema.statics = {
/**