-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
sean
committed
Sep 5, 2017
1 parent
2aeddb9
commit e4395be
Showing
16 changed files
with
187 additions
and
17 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -40,4 +40,5 @@ module.exports = { | |
"strict": 0, | ||
"comma-dangle": ["error", "never"] | ||
} | ||
}; | ||
}; | ||
|
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 |
---|---|---|
|
@@ -31,6 +31,7 @@ | |
"/fekit_modules/*", | ||
"/node_modules/*", | ||
"/bower_components/*", | ||
"/plugins/*", | ||
"/dev/*", | ||
"/prd/*" | ||
] | ||
|
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import './plugin' | ||
import React from 'react' | ||
import ReactDOM from 'react-dom' | ||
import App from './Application' | ||
|
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,34 @@ | ||
const config = process.env.config; | ||
|
||
var hooks = { | ||
'third_login': { | ||
type: 'single', | ||
component: null | ||
}, | ||
'add_interface': { | ||
type: 'mulit', | ||
component: [] | ||
} | ||
}; | ||
|
||
function bindHook(name, component) { | ||
if (!name) throw new Error('缺少hookname'); | ||
if (name in hooks === false) { | ||
throw new Error('不存在的hookname'); | ||
} | ||
if (hooks[name].type === 'multi') { | ||
hooks[name].component.push(component); | ||
} else { | ||
hooks[name].component = component; | ||
} | ||
|
||
} | ||
|
||
if (config.plugins && Array.isArray(config.plugins)) { | ||
config.plugins.forEach(plugin => { | ||
let pluginModule = require(`/Users/sean/qunar/yapi/yapi/node_modules/yapi-plugin-${plugin}/client.js`); | ||
pluginModule(bindHook); | ||
}) | ||
} | ||
|
||
module.exports = hooks; |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"watch": ["server/"] | ||
"watch": ["server/", "common/", "plugins"] | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React from 'react'; | ||
const Qsso = require('./Qsso.js'); | ||
|
||
class QssoComponent extends React.Component{ | ||
componentDidMount(){ | ||
Qsso.attach('qsso-login', '/api/user/login_by_token') | ||
} | ||
|
||
render(){ | ||
return <button id="qsso-login" className="btn-home btn-home-normal" >QSSO 登录</button> | ||
} | ||
} | ||
|
||
|
||
|
||
module.exports = function(bindHook){ | ||
bindHook('third_login', QssoComponent); | ||
}; | ||
|
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,28 @@ | ||
const request = require('request'); | ||
|
||
module.exports = function () { | ||
this.bindHook('third_login', () => { | ||
return { | ||
request: (token) => { | ||
return new Promise((resolve, reject) => { | ||
request('http://qsso.corp.qunar.com/api/verifytoken.php?token=' + token, function (error, response, body) { | ||
if (!error && response.statusCode == 200) { | ||
let result = JSON.parse(body); | ||
if (result && result.ret === true) { | ||
let ret = { | ||
email: result.userId + '@qunar.com', | ||
username: result.data.userInfo.name | ||
}; | ||
resolve(ret); | ||
} else { | ||
reject(result); | ||
} | ||
} | ||
reject(error); | ||
}); | ||
}); | ||
}, | ||
tokenField: 'token' | ||
}; | ||
}) | ||
} |
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,11 @@ | ||
const yapi = require('./yapi.js'); | ||
const plugin_path = yapi.path.join(yapi.WEBROOT, 'plugins') | ||
|
||
module.exports = function(){ | ||
if(yapi.WEBCONFIG.plugins && Array.isArray(yapi.WEBCONFIG.plugins)){ | ||
yapi.WEBCONFIG.plugins.forEach(plugin=>{ | ||
let pluginModule = require(yapi.path.join(plugin_path, 'qsso/server.js')); | ||
pluginModule.call(yapi) | ||
}) | ||
} | ||
} |
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