workplus-api
Version:
WorkPlus API For Node
30 lines (24 loc) • 708 B
JavaScript
/**
* Created by luomin on 16/7/7.
*/
;
let Client = require('./client');
class Ticket {
constructor(ticket, clientId, orgId) {
this.ticket = ticket;
this.clientId = clientId;
this.orgId = orgId;
}
verify(params) {
return Client.verifyTicket(this.ticket, params).then(data => {
if (data.result.client_id !== this.clientId) {
throw new Error('当前ticket不合法, 用户不匹配');
}
if (data.result.org_id !== this.orgId) {
throw new Error('当前ticket不合法, 组织不匹配');
}
return data.result;
});
}
}
module.exports = Ticket;