Skip to content

Commit 7a8dc47

Browse files
author
oguzhan.onder
committed
post,get,delete,put methods moved in service object.
1 parent fef4315 commit 7a8dc47

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/store/actions.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,8 @@ export const getTradeResult = ({commit}) => {
2222

2323

2424
export const login = (vueContext, loginData) => {
25-
let password = loginData.password;
26-
let username = loginData.username;
27-
let rndUser = Math.random().toString(36).substr(2, 6);
28-
let rndPass = Math.random().toString(36).substr(2, 6);
29-
loginData.password = btoa(btoa(password + util.rndData + rndPass));
30-
loginData.username = btoa(btoa(username + util.rndData + rndUser));
25+
loginData.password = util.randomCode(loginData.password);
26+
loginData.username = util.randomCode(loginData.username);
3127

3228
return util.service.post("auth/login", loginData)
3329
.then(response => {
@@ -60,6 +56,8 @@ export const userRegister = (vueContext, registerData) => {
6056
if (response) {
6157
return response;
6258
}
59+
}).catch(error=>{
60+
registerData = {};
6361
})
6462
};
6563

src/util/util.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ export const notify = {
1717
}
1818
};
1919

20+
export const randomCode = function (data) {
21+
let rndKey = Math.random().toString(36).substr(2, 6);
22+
return btoa(btoa(data + rndData + rndKey));
23+
};
24+
2025
export const service = {
2126

2227
get(url){

0 commit comments

Comments
 (0)