|
|
@@ -2,6 +2,7 @@
|
|
|
const config = require("../config.js")
|
|
|
,Slack = require("../src/slack.js").Slack
|
|
|
,GoogleOAuth = require("../src/googleOAuth.js").GoogleOAuth
|
|
|
+ ,FacebookOAuth = require("../src/facebookOAuth.js").FacebookOAuth
|
|
|
,slackManager = require("../src/slackManager.js").SlackManager
|
|
|
,accountManager = require("../src/accounts.js").accountManager
|
|
|
,templates = require('./_templates.js');
|
|
|
@@ -26,7 +27,7 @@ function checkTokens(service, req, cb) {
|
|
|
|
|
|
case "google":
|
|
|
if (req.urlObj.queryTokens.code) {
|
|
|
- GoogleOAuth.getUserMail(req.urlObj.queryTokens.code, (id) => {
|
|
|
+ GoogleOAuth.getUserId(req.urlObj.queryTokens.code, (id) => {
|
|
|
if (id) {
|
|
|
console.log("from google id " +id);
|
|
|
var account = accountManager.fromGoogleIdAuth(id);
|
|
|
@@ -40,6 +41,22 @@ function checkTokens(service, req, cb) {
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
+ case "facebook":
|
|
|
+ if (req.urlObj.queryTokens.code) {
|
|
|
+ FacebookOAuth.getUserId(req.urlObj.queryTokens.code[0], (id) => {
|
|
|
+ if (id) {
|
|
|
+ console.log("from facebook id " +id);
|
|
|
+ var account = accountManager.fromFacebookIdAuth(id);
|
|
|
+ cb(account);
|
|
|
+ } else {
|
|
|
+ cb(null);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ cb(null);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
default:
|
|
|
cb(null);
|
|
|
break;
|
|
|
@@ -48,20 +65,24 @@ function checkTokens(service, req, cb) {
|
|
|
|
|
|
function makeLoginPage() {
|
|
|
const
|
|
|
- slackUri = config.login.slack.endpoint
|
|
|
+ slackUri = config.login.slack.requestLoginUri
|
|
|
+"?client_id=" +config.login.slack.clientId
|
|
|
+"&scope=" +slackManager.getAuthScope().join(',')
|
|
|
+"&redirect_uri=" +config.login.slack.redirect_uri,
|
|
|
- googleUri = config.login.google.endpoint
|
|
|
+ googleUri = config.login.google.requestLoginUri
|
|
|
+"?client_id=" +config.login.google.clientId
|
|
|
+"&scope=" +(["openid", "email", "profile"]).join("%20")
|
|
|
+"&redirect_uri=" +config.login.google.redirect_uri
|
|
|
- +"&response_type=code";
|
|
|
+ +"&response_type=code"
|
|
|
+ facebookUri = config.login.facebook.requestLoginUri
|
|
|
+ +"?client_id=" +config.login.facebook.clientId
|
|
|
+ +"&redirect_uri=" +config.login.facebook.redirect_uri;
|
|
|
|
|
|
return templates.header("Mimou - login", ["login.css"])
|
|
|
+`<div class="services"><h1>Login</h1>`
|
|
|
- +`<a href="${slackUri}"><img src="https://platform.slack-edge.com/img/sign_in_with_slack.png" srcset="https://platform.slack-edge.com/img/sign_in_with_slack.png 1x, https://platform.slack-edge.com/img/sign_in_with_slack@2x.png 2x" /></a>`
|
|
|
+`<a href="${googleUri}"><img src="https://developers.google.com/identity/images/btn_google_signin_light_normal_web.png" alt="Sign in with Google" class="attempt-right"></a>`
|
|
|
+ +`<a href="${facebookUri}"><img src="${config.rootUrl}btn_facebook_connect.png" alt="Log in with facebook"/></a>`
|
|
|
+ +`<a href="${slackUri}"><img src="https://platform.slack-edge.com/img/sign_in_with_slack.png" srcset="https://platform.slack-edge.com/img/sign_in_with_slack.png 1x, https://platform.slack-edge.com/img/sign_in_with_slack@2x.png 2x" /></a>`
|
|
|
+`</div>`
|
|
|
+templates.footer();
|
|
|
}
|