Add user password encryption
parent
c7f137c48a
commit
1f4be16a1d
|
@ -33,6 +33,7 @@
|
||||||
"rxjs": "^5.0.1",
|
"rxjs": "^5.0.1",
|
||||||
"socket.io-client": "^1.4.8",
|
"socket.io-client": "^1.4.8",
|
||||||
"ts-helpers": "^1.1.1",
|
"ts-helpers": "^1.1.1",
|
||||||
|
"ts-md5": "^1.2.0",
|
||||||
"zone.js": "^0.7.2"
|
"zone.js": "^0.7.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
@ -35,21 +35,21 @@
|
||||||
{
|
{
|
||||||
"id": 301,
|
"id": 301,
|
||||||
"name": "admin",
|
"name": "admin",
|
||||||
"password": "admin",
|
"password": "ff9830c42660c1dd1942844f8069b74a",
|
||||||
"edit_tasks": true,
|
"edit_tasks": true,
|
||||||
"change_settings": true
|
"change_settings": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 302,
|
"id" : 302,
|
||||||
"name": "user_edit",
|
"name": "user_edit",
|
||||||
"password": "secret",
|
"password": "ea847988ba59727dbf4e34ee75726dc3",
|
||||||
"edit_tasks": true,
|
"edit_tasks": true,
|
||||||
"change_settings": false
|
"change_settings": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 303,
|
"id" : 303,
|
||||||
"name": "user",
|
"name": "user",
|
||||||
"password": "secret",
|
"password": "5ebe2294ecd0e0f08eab7690d2a6ee69",
|
||||||
"edit_tasks": false,
|
"edit_tasks": false,
|
||||||
"change_settings": false
|
"change_settings": false
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import {Http} from '@angular/http';
|
||||||
import {Observable} from 'rxjs/Observable';
|
import {Observable} from 'rxjs/Observable';
|
||||||
import {UserStore} from '../stores/user.store';
|
import {UserStore} from '../stores/user.store';
|
||||||
import {SOCKET_IO, AUTH_ENABLED} from '../../app.tokens';
|
import {SOCKET_IO, AUTH_ENABLED} from '../../app.tokens';
|
||||||
|
import {Md5} from 'ts-md5/dist/md5';
|
||||||
|
|
||||||
const BASE_URL = `http://localhost:3000/api/users`;
|
const BASE_URL = `http://localhost:3000/api/users`;
|
||||||
|
|
||||||
|
@ -34,7 +35,8 @@ export class LoginService {
|
||||||
login(name, password) {
|
login(name, password) {
|
||||||
if (this.getUser(name)) {
|
if (this.getUser(name)) {
|
||||||
let user = this.results$[0];
|
let user = this.results$[0];
|
||||||
if (user && user.password === password) {
|
let passMd5 = Md5.hashStr(password);
|
||||||
|
if (user && user.password === passMd5) {
|
||||||
localStorage.setItem(CURRENT_USER, JSON.stringify(user));
|
localStorage.setItem(CURRENT_USER, JSON.stringify(user));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue