@waline/vercel 1.3.1 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@waline/vercel",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "vercel server for waline comment system",
5
5
  "repository": "https://github.com/walinejs/waline",
6
6
  "license": "MIT",
@@ -24,7 +24,10 @@ module.exports = class extends think.Controller {
24
24
  type,
25
25
  })}`;
26
26
  return this.redirect(
27
- `${oauthUrl}/${type}?${qs.stringify({ redirect: redirectUrl })}`
27
+ `${oauthUrl}/${type}?${qs.stringify({
28
+ redirect: redirectUrl,
29
+ state: this.ctx.state.token,
30
+ })}`
28
31
  );
29
32
  }
30
33
 
@@ -38,7 +41,10 @@ module.exports = class extends think.Controller {
38
41
  redirect,
39
42
  type,
40
43
  })}`;
41
- params.state = qs.stringify({ redirect: redirectUrl, state: '' });
44
+ params.state = qs.stringify({
45
+ redirect: redirectUrl,
46
+ state: this.ctx.state.token || '',
47
+ });
42
48
  }
43
49
 
44
50
  const user = await request({
@@ -83,7 +89,7 @@ module.exports = class extends think.Controller {
83
89
  objectId: current.objectId,
84
90
  });
85
91
 
86
- return this.success();
92
+ return this.redirect('/ui/profile');
87
93
  }
88
94
 
89
95
  const userByEmail = await this.modelInstance.select({ email: user.email });
@@ -78,7 +78,7 @@ module.exports = class extends BaseRest {
78
78
  }
79
79
 
80
80
  async putAction() {
81
- const { display_name, url, password, github } = this.post();
81
+ const { display_name, url, password } = this.post();
82
82
  const { objectId } = this.ctx.state.userInfo;
83
83
 
84
84
  const updateData = {};
@@ -95,9 +95,13 @@ module.exports = class extends BaseRest {
95
95
  updateData.password = new PasswordHash().hashPassword(password);
96
96
  }
97
97
 
98
- if (think.isString(github)) {
99
- updateData.github = github;
100
- }
98
+ const socials = ['github', 'twitter', 'facebook', 'google', 'weibo', 'qq'];
99
+ socials.forEach((social) => {
100
+ const nextSocial = this.post(social);
101
+ if (think.isString(nextSocial)) {
102
+ updateData[social] = nextSocial;
103
+ }
104
+ });
101
105
 
102
106
  if (think.isEmpty(updateData)) {
103
107
  return this.success();
package/src/logic/base.js CHANGED
@@ -79,5 +79,6 @@ module.exports = class extends think.Logic {
79
79
  userInfo.avatar = avatarUrl;
80
80
  userInfo.mailMd5 = helper.md5(userInfo.email);
81
81
  this.ctx.state.userInfo = userInfo;
82
+ this.ctx.state.token = token;
82
83
  }
83
84
  };