ant-design / ant-design-pro

👨🏻‍💻👩🏻‍💻 Use Ant Design like a Pro!
https://pro.ant.design
MIT License
36.53k stars 8.15k forks source link

Feature request: include api token management #357

Closed andriijas closed 6 years ago

andriijas commented 6 years ago

It would be nice if this project includes how to work with api tokens, when user login it can be saved in app model or user model and somehow used with services / utils/request

thanks

chenshuai2144 commented 6 years ago

just like this redux-auth?

andriijas commented 6 years ago

nah i was thinking something simpler to get the current login in ant pro working. redux auth is overhaul for this project, includes material forms and other unnecessary stuff which will make it confusing for antd users.

chenshuai2144 commented 6 years ago

ui of course use antd. Function similar? A simple manager?

andriijas commented 6 years ago

yes, with example login guest/guest or similar, right now you can login by just going to url and even 404 is on logged in pages.

what do you think of adding basic auth that secures logged in pages, otherwise redicting to login and keep auth state in app model or similar. then api can subscribe to model state if there is auth token in there.

andriijas commented 6 years ago

  namespace: 'login',

  state: {
    status: undefined,
    token: ............
  },

other model:

  import { fakeChartData } from '../services/api';
      const response = yield call(fakeChartData, payload);

How can I wrap fakeChartData to send token from login model?

lawrence-peng commented 6 years ago

see #298 @andriijas