Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static login(user_name, user_pass, user_ip, user_agent)
- {
- return new Promise((resolve, reject) =>
- {
- if(user_name == null || user_pass == null || user_ip == null || user_agent == null) return reject(new Error('invalid_parameters'));
- return new HotelUserDB({username: user_name}).fetch({
- columns: ['id', 'username', 'password', 'auth_ticket', 'ip_current']
- })
- .then((result) =>
- {
- if(result == null) return this.log_login(0, user_name, user_ip, user_agent, false)
- .then((result) =>
- {
- return reject(new Error('invalid_login'));
- });
- let user_info = result.toJSON();
- var chaineRetroPHP = "xCg532%@%gdvf^5DGaa6&*rFTfg^FD4\$OIFThrR_gh(ugf*/";
- if(sha1(user_pass + chaineRetroPHP) !== user_info.password) return this.log_login(user_info.id, user_info.username, user_ip, user_agent, false)
- .then((result) =>
- {
- return reject(new Error('invalid_login'));
- });
- return Session.create_session(user_info.id, user_info.username, user_ip, user_agent)
- .then((session) =>
- {
- if(session == null) return reject(new Error('invalid_session'));
- result.set({auth_ticket: session.user_session, ip_current: user_ip});
- return result.save()
- .then((result) =>
- {
- return this.log_login(user_info.id, user_info.username, user_ip, user_agent, true)
- .then((result) =>
- {
- return resolve(session);
- })
- })
- })
- .catch((err) =>
- {
- return reject(err);
- });
- })
- .catch((err) =>
- {
- return reject(err);
- })
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement