forked from OpenUserJS/OpenUserJS.org
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A commit so massive I would need to write a novel than just a message…
…. But it closes #1.
- Loading branch information
1 parent
c3b6596
commit 390b095
Showing
11 changed files
with
200 additions
and
70 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
var passport = require('passport'); | ||
var URL = process.env.NODE_ENV === 'production' ? | ||
'openuserjs.org' : 'localhost:8080'; | ||
|
||
exports.strategyInstances = {}; | ||
|
||
// This will load a single passport | ||
exports.loadPassport = function(strategy) { | ||
//console.log(strategy); | ||
var requireStr = 'passport-' + strategy.name; | ||
var PassportStrategy = require(requireStr).Strategy; | ||
var instance = null; | ||
|
||
if(strategy.openid) { | ||
instance = new PassportStrategy( | ||
{ | ||
returnURL: 'http://' + URL + '/auth/' + strategy.name + '/callback/', | ||
realm: 'http://' + URL + '/' | ||
}, | ||
function() {} | ||
); | ||
} else { | ||
instance = new PassportStrategy( | ||
{ | ||
consumerKey: strategy.id, | ||
consumerSecret: strategy.key, | ||
clientID: strategy.id, | ||
clientSecret: strategy.key, | ||
callbackURL: 'http://' + URL + '/auth/' + strategy.name + '/callback/' | ||
}, | ||
function() {} | ||
); | ||
} | ||
|
||
exports.strategyInstances[strategy.name] = instance; | ||
passport.use(instance); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// A simple way of waiting for a bunch of async calls to finish | ||
// Call the constructor with the function you want run when everything is done | ||
// Add functions that you want to wait to get called | ||
// Basically callbacks to async functions | ||
|
||
// So instead of: | ||
// asyncFunction(callback); | ||
|
||
// Do: | ||
// var wait = new Wait(function() { console.log('done'); }); | ||
// asyncFunction(wait.add(callback)); | ||
|
||
function Wait(last) { | ||
this.counter = 0; | ||
this.done = function() { | ||
if (this.counter) return; | ||
last(); | ||
}; | ||
} | ||
|
||
Wait.prototype.add = function(task) { | ||
++this.counter; | ||
|
||
var wait = this; | ||
return (function() { | ||
task.apply(null, Array.prototype.slice.apply(arguments)); | ||
--wait.counter; | ||
wait.done(); | ||
}); | ||
} | ||
|
||
exports.Wait = Wait; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<html> | ||
<head> | ||
<title>User Administration</title> | ||
</head> | ||
<body> | ||
<form method="post" action="/admin/user/update"> | ||
{{#users}} | ||
<strong>{{name}}</strong> | Role: | ||
<select name="user[{{name}}]"> | ||
{{#roles}} | ||
<option value="{{val}}" {{#selected}}selected="{{selected}}"{{/selected}}> | ||
{{display}}</option> | ||
{{/roles}} | ||
</select> | Remove: | ||
<input type="checkbox" name="remove[{{name}}]" value="{{user}}"><br /> | ||
{{/users}} | ||
<input type="submit" value="Update" /> | ||
</form> | ||
</body> | ||
</html> | ||
<html> |