Skip to content

Commit

Permalink
✨ modify page
Browse files Browse the repository at this point in the history
  • Loading branch information
tookbra committed Jul 1, 2019
1 parent 30cf6f6 commit 9ea0b23
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 31 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"dependencies": {
"ant-design-vue": "1.3.10",
"axios": "0.19.0",
"bcryptjs": "^2.4.3",
"core-js": "^2.6.5",
"enquire.js": "^2.1.6",
"js-cookie": "^2.2.0",
Expand Down
7 changes: 2 additions & 5 deletions src/api/account/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ import { fetch } from "@/libs/fetch";

export function getAccountInfo() {
return fetch({
url: "/account/info",
method: "get",
headers: {
"Content-Type": "application/json;charset=UTF-8"
}
url: "/system/accounts/info",
method: "get"
});
}
7 changes: 2 additions & 5 deletions src/api/account/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export function login(parameter) {
url: "/auth/oauth/token",
method: "post",
headers: {
Authorization: "Basic cGlnOnBpZw=="
Authorization: "Basic bmFubnk6bmFubnk="
},
params: Object.assign(parameter, { grant_type: grant_type, scope: scope })
});
Expand All @@ -16,9 +16,6 @@ export function login(parameter) {
export function logout() {
return fetch({
url: "/auth/logout",
method: "post",
headers: {
"Content-Type": "application/json;charset=UTF-8"
}
method: "post"
});
}
13 changes: 2 additions & 11 deletions src/components/login/user-login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
</template>

<script>
import md5 from "md5";
import { mapActions } from "vuex";
export default {
name: "UserLogin",
Expand All @@ -106,15 +105,8 @@ export default {
if (!err) {
console.log("Received values of form: ", values);
const loginParams = { ...values };
loginParams.password = md5(values.password);
Login(loginParams)
.then(res => {
if (res.success) {
this.loginSuccess(res);
} else {
this.requestFailed(res.msg);
}
})
.then(() => this.loginSuccess())
.catch(err => this.requestFailed(err))
.finally(() => {
state.loginBtn = false;
Expand All @@ -126,8 +118,7 @@ export default {
}
});
},
loginSuccess(res) {
console.log(res);
loginSuccess() {
this.$router.push({ name: "home" });
},
requestFailed(err) {
Expand Down
2 changes: 1 addition & 1 deletion src/libs/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const fetch = axios.create({

fetch.interceptors.request.use(config => {
if (store.state.account.token) {
config.headers.Authorization = store.state.account.token;
config.headers.Authorization = "Bearer " + store.state.account.token;
}
return config;
}, err);
Expand Down
17 changes: 8 additions & 9 deletions src/store/modules/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@ export default {
return new Promise((resolve, reject) => {
login(userInfo)
.then(response => {
if (response.success) {
const result = response.data;
Vue.ls.set(ACCESS_TOKEN, result.token, 7 * 24 * 60 * 60 * 1000);
commit("SET_TOKEN", result.token);
resolve();
} else {
reject(response.msg);
}
Vue.ls.set(
ACCESS_TOKEN,
response.access_token,
7 * 24 * 60 * 60 * 1000
);
commit("SET_TOKEN", response.access_token);
resolve();
})
.catch(error => {
reject(error);
Expand All @@ -43,7 +42,7 @@ export default {
getAccountInfo()
.then(response => {
const result = response.data;
if (result.role && result.role.permissions.length > 0) {
if (result.role && result.permissions.length > 0) {
const role = result.role;
role.permissions = result.role.permissions;
role.permissions.map(per => {
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1415,6 +1415,11 @@ bcrypt-pbkdf@^1.0.0:
dependencies:
tweetnacl "^0.14.3"

bcryptjs@^2.4.3:
version "2.4.3"
resolved "https://registry.npm.taobao.org/bcryptjs/download/bcryptjs-2.4.3.tgz#9ab5627b93e60621ff7cdac5da9733027df1d0cb"
integrity sha1-mrVie5PmBiH/fNrF2pczAn3x0Ms=

bfj@^6.1.1:
version "6.1.1"
resolved "https://registry.yarnpkg.com/bfj/-/bfj-6.1.1.tgz#05a3b7784fbd72cfa3c22e56002ef99336516c48"
Expand Down

0 comments on commit 9ea0b23

Please sign in to comment.