Commit 5b5e54a5 authored by Davve's avatar Davve

关闭权限认证

parent d2380993
......@@ -15,13 +15,14 @@ class AccountList(APIView):
data = self.rpc['venus/community/pick/get'](offset=page, limit=limit, filters=filter).unwrap()
except Exception as e:
# raise e
data = {
'total': 100,
'data': [
{'id': 1, 'nickname': '鹿晗1', 'password': '21233423', 'email': 'www.baidu.com', 'username': 'admin1'},
{'id': 2, 'nickname': '鹿晗2', 'password': '21233423', 'email': 'www.baidu.com', 'username': 'admin2'},
{'id': 3, 'nickname': '鹿晗3', 'password': '21233423', 'email': 'www.baidu.com', 'username': 'admin3'},
{'id': 4, 'nickname': '鹿晗4', 'password': '21233423', 'email': 'www.baidu.com', 'username': 'admin4'},
pass
data = {
'total': 100,
'data': [
{'id': 1, 'nickname': '鹿晗1', 'password': '21233423', 'email': 'www.baidu.com', 'username': 'admin1'},
{'id': 2, 'nickname': '鹿晗2', 'password': '21233423', 'email': 'www.baidu.com', 'username': 'admin2'},
{'id': 3, 'nickname': '鹿晗3', 'password': '21233423', 'email': 'www.baidu.com', 'username': 'admin3'},
{'id': 4, 'nickname': '鹿晗4', 'password': '21233423', 'email': 'www.baidu.com', 'username': 'admin4'},
]
}
return data
......@@ -65,4 +66,28 @@ class LoginView(APIView):
class LogoutView(APIView):
def post(self, request):
pass
\ No newline at end of file
pass
class AccountUpdateOrCreateView(APIView):
def get(self, request):
map = {
'admin': {
'roles': ['admin'],
'token': 'admin',
'introduction': '我是超级管理员',
'avatar': 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
'name': 'Super Admin'
},
'editor': {
'roles': ['editor'],
'token': 'editor',
'introduction': '我是编辑',
'avatar': 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
'name': 'Normal Editor'
}
}
token = request.GET.get('token')
return {
'data': map['admin']
}
\ No newline at end of file
......@@ -8,11 +8,11 @@ from utils.base import APIView
class GroupListView(APIView):
def get(self, request):
page = request.GET.get('page', 1)
limit = request.GET.get('limit', 10)
filter = self.handle_filter(request.GET.get('filter', ""))
offset = request.GET.get('page', 1)
count = request.GET.get('limit', 10)
filters = self.handle_filter(request.GET.get('filter', ""))
try:
data = self.rpc['venus/community/group/get'](offset=page, limit=limit, filters=filter).unwrap()
data = self.rpc['venus/community/group/list'](filters=filters, offset=offset, count=count).unwrap()
except Exception as e:
# raise e
data = {
......
......@@ -20,8 +20,8 @@ urlpatterns = [
url(r'account/logout', LogoutView.as_view()),
url(r'account/list', AccountList.as_view()),
url(r'account/update', AccountList.as_view()),
url(r'account/get', UpdateOrCreateView.as_view()),
url(r'account/create', UpdateOrCreateView.as_view()),
url(r'account/get', AccountUpdateOrCreateView.as_view()),
url(r'account/create', AccountUpdateOrCreateView.as_view()),
# user相关
url(r'user/list$', UserListView.as_view()),
......
......@@ -21,7 +21,7 @@ export function logout() {
export function getUserInfo(token) {
return request({
url: '/user/info',
url: '/api/account/get',
method: 'get',
params: { token }
})
......
......@@ -19,7 +19,7 @@ Mock.XHR.prototype.send = function() {
// })
// 登录相关
// Mock.mock(/\/login\/login/, 'post', loginAPI.loginByUsername)
Mock.mock(/\/login\/login/, 'post', loginAPI.loginByUsername)
Mock.mock(/\/login\/logout/, 'post', loginAPI.logout)
Mock.mock(/\/user\/info\.*/, 'get', loginAPI.getUserInfo)
......
......@@ -48,14 +48,14 @@ const permission = {
actions: {
GenerateRoutes({ commit }, data) {
return new Promise(resolve => {
const { roles } = data
let accessedRouters
if (roles.includes('admin')) {
accessedRouters = asyncRouterMap
} else {
accessedRouters = filterAsyncRouter(asyncRouterMap, roles)
}
commit('SET_ROUTERS', accessedRouters)
// const { roles } = data
// const accessedRouters = asyncRouterMap
// if (roles.includes('admin')) {
// accessedRouters = asyncRouterMap
// } else {
// accessedRouters = filterAsyncRouter(asyncRouterMap, roles)
// }
commit('SET_ROUTERS', asyncRouterMap)
resolve()
})
}
......
......@@ -53,7 +53,8 @@ const user = {
const username = userInfo.username.trim()
return new Promise((resolve, reject) => {
loginByUsername(username, userInfo.password).then(response => {
const data = response.data.data
const data = response.data
console.log(data)
commit('SET_TOKEN', data.token)
commit('SET_ID', data.id)
setToken(response.data.token)
......@@ -71,8 +72,7 @@ const user = {
if (!response.data) { // 由于mockjs 不支持自定义状态码只能这样hack
reject('error')
}
const data = response.data
const data = response.data.data.data
if (data.roles && data.roles.length > 0) { // 验证返回的roles是否是一个非空数组
commit('SET_ROLES', data.roles)
} else {
......
......@@ -127,6 +127,7 @@ export function param2Obj(url) {
if (!search) {
return {}
}
console.log(url)
return JSON.parse(
'{"' +
decodeURIComponent(search)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment