Skip to content

Commit

Permalink
fix request后session.clear()
Browse files Browse the repository at this point in the history
  • Loading branch information
c708423 committed May 31, 2018
1 parent cc78b50 commit 07dc45d
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 5 deletions.
2 changes: 2 additions & 0 deletions client/pages/index/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ Page({
success: function () {
// 登录态未过期
util.showSuccess('登陆成功');
console.log('登陆态未过期');
that.setData({
userInfo: userInfo,
logged: true
Expand All @@ -164,6 +165,7 @@ Page({
fail: function () {
qcloud.clearSession();
// 登录态已过期,需重新登录
console.log('登陆态已过期');
var options = {
encryptedData: e.detail.encryptedData,
iv: e.detail.iv,
Expand Down
1 change: 1 addition & 0 deletions client/pages/postinfo/postinfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ Page({
}
qcloud.request({
url: config.service.hosturl + 'infopost',
method:"post",
data:{
classify:that.data.classify_map[that.data.nowclass],
content:that.data.content,
Expand Down
1 change: 1 addition & 0 deletions client/vendor/wafer2-client-sdk/lib/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ var requestLogin = function requestLogin(options) {
success: function (result) {
var data = result.data;
// 成功地响应会话信息
console.log('requestlogin',result);
if (data && data.code === 0 && data.data.skey) {
var res = data.data

Expand Down
1 change: 0 additions & 1 deletion client/vendor/wafer2-client-sdk/lib/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ function request(options) {

var error, message;
if (data && data.code === -1) {
Session.clear();
// 如果是登录态无效,并且还没重试过,会尝试登录后刷新凭据重新请求
if (!hasRetried) {
hasRetried = true;
Expand Down
2 changes: 1 addition & 1 deletion server/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const CONF = {
*/
region: 'ap-guangzhou',
// Bucket 名称
fileBucket: 'qcloudtest-1253153042',
fileBucket: 'qcloudtest',
// 文件夹
uploadFolder: ''
},
Expand Down
1 change: 1 addition & 0 deletions server/middlewares/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module.exports = async function (ctx, next) {
// 处理响应结果
// 如果直接写入在 body 中,则不作处理
// 如果写在 ctx.body 为空,则使用 state 作为响应
debug(ctx.body)
ctx.body = ctx.body ? ctx.body : {
code: ctx.state.code !== undefined ? ctx.state.code : 0,
data: ctx.state.data !== undefined ? ctx.state.data : {}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 07dc45d

Please sign in to comment.