|
@@ -40,12 +40,26 @@ class LoginService extends CrudService {
|
|
|
const { secret, expiresIn = '1d', issuer = type } = this.config.jwt;
|
|
|
const subject = mobile;
|
|
|
let _userid = '';
|
|
|
+ let res = {};
|
|
|
if (type === '0') {
|
|
|
_userid = _id.toString();
|
|
|
- } else {
|
|
|
+ } else if (type === '1') {
|
|
|
+ _userid = uid.toString();
|
|
|
+ res = await this.hModel.findById(_userid);
|
|
|
+ } else if (type === '2') {
|
|
|
+ _userid = uid.toString();
|
|
|
+ res = await this.schModel.findById(_userid);
|
|
|
+ } else if (type === '3') {
|
|
|
+ _userid = uid.toString();
|
|
|
+ res = await this.tModel.findById(_userid);
|
|
|
+ } else if (type === '4') {
|
|
|
_userid = uid.toString();
|
|
|
+ res = await this.stuModel.findById(_userid);
|
|
|
}
|
|
|
- const token = await jwt.sign({ userid: _userid, name, openid, type }, secret, { expiresIn, issuer, subject });
|
|
|
+ res.userid = _userid;
|
|
|
+ res.openid = openid;
|
|
|
+ res.type = type;
|
|
|
+ const token = await jwt.sign(res, secret, { expiresIn, issuer, subject });
|
|
|
return token;
|
|
|
}
|
|
|
|