Skip to content

Commit

Permalink
fix: optional chaining
Browse files Browse the repository at this point in the history
  • Loading branch information
gozeon committed Mar 9, 2024
1 parent af0891b commit 2a76b12
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"koa-static": "3.0.0",
"koa-websocket": "4.0.0",
"ldapjs": "^1.0.1",
"lodash.get": "^4.4.2",
"markdown-it": "8.4.0",
"markdown-it-anchor": "4.0.0",
"markdown-it-table-of-contents": "0.3.2",
Expand Down
3 changes: 2 additions & 1 deletion server/controllers/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const shareModel = require('../models/share.js');
const _ = require('underscore');
const jwt = require('jsonwebtoken');
const {parseToken} = require('../utils/token')
const loGet = require('lodash.get')

class baseController {
constructor(ctx) {
Expand Down Expand Up @@ -213,7 +214,7 @@ class baseController {
}

getRole() {
return this.$user?.role;
return loGet(this.$user, 'role', void 0);
}

getUsername() {
Expand Down
4 changes: 3 additions & 1 deletion server/controllers/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ const projectModel = require('../models/project.js');
const avatarModel = require('../models/avatar.js');

const jwt = require('jsonwebtoken');
const loGet = require('lodash.get')


class userController extends baseController {
constructor(ctx) {
Expand Down Expand Up @@ -343,7 +345,7 @@ class userController extends baseController {
try {
let user = await userInst.save(data);

ctx.request.body?.action !== 'append' && this.setLoginCookie(user._id, user.passsalt);
loGet(ctx, 'request.body.action', '')!== 'append' && this.setLoginCookie(user._id, user.passsalt);
await this.handlePrivateGroup(user._id, user.username, user.email);
ctx.body = yapi.commons.resReturn({
uid: user._id,
Expand Down

0 comments on commit 2a76b12

Please sign in to comment.