MR
Size: a a a
MR
ES
YZ
ES
ES
public toPlainObject() {
return {
id: this.id,
login: this.login,
isSendEmail: this.isSendEmail,
phone: this.phone,
createdAt: this.createdAt,
gender: this.gender,
email: this.email,
firstName: this.firstName,
lastName: this.lastName,
middleName: this.middleName,
residenceIndex: this.residenceIndex,
residenceHouse: this.residenceHouse,
residenceFlat: this.residenceFlat,
residenceOther: this.residenceOther,
del: this.del,
tmp: this.tmp,
rememberToken: this.rememberToken,
streetId: this.streetId,
btaId: this.btaId,
kontId: this.kontId,
roleId: this.roleId
}
}ES
ES
М
YZ
М
const get_user_by_phone = (phone) => new PromisePromise((resolve, reject) => {
dbdb.employees.findOne({
where: { phone },
raw: true
}).then((user) => {
resolve(user);
}).catch((err) => {
reject(err);
});
});YZ
YZ
М
module.exports.get_user = (req, res) => {
let info,
user_jwt;
get_token(req.query.code).then((token) => {
user_jwt = token;
req.session.user = {};
info = jwtjwt.decode(token);
const phone = jwtjwt.decode(token).user_name.slice(1);
return fn.get_user_by_phone(phone); }).then((user) => {
if (user) {
req.session.user.id = user.id;
req.session.user.full_name = user.fio;
req.session.user.exp = DateDate.now() + 30 * 60 * 1000;
return req.session.user.id;
}
return add_new_employee(user_jwt);
}).then((user_id) => {
if (user_id) {
return get_user_accesses(user_id);
}
}).then((access) => {
if (access) {
req.session.user.roles = access;
}
req.session.user.filter = {
status: [1, 2, 3, 4, 5, 6, 7],
group: false,
classification: req.session.user.roles.admin.concat(req.session.user.roles.executor),
request: null,
create: null,
description: "%",
details: null
};
res.redirect('/');
}).catch((err) => {
consoleconsole.log(err);
res.redirect('/login');
});
};YZ
М
YZ
YZ