forked from scrollback/scrollback
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestauth.js
27 lines (26 loc) · 791 Bytes
/
testauth.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
var config = require("../config.js"),
name = require("../lib/generate.js").word,
log = require("../lib/logger.js"),
request = require("request");
var SbError = require("../../lib/SbError.js");
module.exports = function(core) {
core.on('init', function(action, callback) {
if(!action.auth || !action.auth.testauth) return callback();
var testauth = action.auth.testauth || "";
if(action.type !== 'init' || !action.auth || !action.auth.testauth) return callback();
delete action.auth.testauth;
if(testauth == "user1:1234567890") {
action.user = {
id:"testUser1"
}
callback();
}else if(testauth == "user2:0987654321") {
action.user = {
id:"testUser2"
}
callback();
}else {
callback(new SbError("AUTH_UNREGISTERED"));
}
}, "authentication");
};