mirror of
https://github.com/MisskeyIO/misskey
synced 2024-12-01 00:08:24 +09:00
Merge branch 'master' of https://github.com/syuilo/misskey
This commit is contained in:
commit
588f35a16a
18
package.json
18
package.json
@ -47,13 +47,13 @@
|
||||
"@types/is-root": "1.0.0",
|
||||
"@types/is-url": "1.2.28",
|
||||
"@types/js-yaml": "3.9.0",
|
||||
"@types/mocha": "2.2.42",
|
||||
"@types/mocha": "2.2.43",
|
||||
"@types/mongodb": "2.2.11",
|
||||
"@types/monk": "1.0.6",
|
||||
"@types/morgan": "1.7.32",
|
||||
"@types/ms": "0.7.30",
|
||||
"@types/multer": "1.3.2",
|
||||
"@types/node": "8.0.27",
|
||||
"@types/node": "8.0.28",
|
||||
"@types/ratelimiter": "2.1.28",
|
||||
"@types/redis": "2.6.0",
|
||||
"@types/request": "2.0.3",
|
||||
@ -80,7 +80,7 @@
|
||||
"gulp-typescript": "3.2.2",
|
||||
"gulp-uglify": "3.0.0",
|
||||
"gulp-util": "3.0.8",
|
||||
"mocha": "3.5.0",
|
||||
"mocha": "3.5.3",
|
||||
"riot-tag-loader": "1.0.0",
|
||||
"string-replace-webpack-plugin": "0.1.3",
|
||||
"style-loader": "0.18.2",
|
||||
@ -91,14 +91,14 @@
|
||||
"uglify-es": "3.0.27",
|
||||
"uglify-es-webpack-plugin": "0.10.0",
|
||||
"uglify-js": "git+https://github.com/mishoo/UglifyJS2.git#harmony",
|
||||
"webpack": "3.5.6"
|
||||
"webpack": "3.6.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"accesses": "2.5.0",
|
||||
"animejs": "2.0.2",
|
||||
"autwh": "0.0.1",
|
||||
"bcryptjs": "2.4.3",
|
||||
"body-parser": "1.17.2",
|
||||
"body-parser": "1.18.1",
|
||||
"cafy": "2.4.0",
|
||||
"chalk": "2.1.0",
|
||||
"compression": "1.7.0",
|
||||
@ -119,11 +119,11 @@
|
||||
"inquirer": "3.2.3",
|
||||
"is-root": "1.0.0",
|
||||
"is-url": "1.2.2",
|
||||
"js-yaml": "3.9.1",
|
||||
"js-yaml": "3.10.0",
|
||||
"mecab-async": "^0.1.0",
|
||||
"moji": "^0.5.1",
|
||||
"mongodb": "2.2.31",
|
||||
"monk": "6.0.3",
|
||||
"monk": "6.0.4",
|
||||
"morgan": "1.8.2",
|
||||
"ms": "2.0.0",
|
||||
"multer": "1.3.0",
|
||||
@ -138,11 +138,11 @@
|
||||
"reconnecting-websocket": "3.2.1",
|
||||
"redis": "2.8.0",
|
||||
"request": "2.81.0",
|
||||
"rimraf": "2.6.1",
|
||||
"rimraf": "2.6.2",
|
||||
"riot": "3.7.0",
|
||||
"rndstr": "1.0.0",
|
||||
"s-age": "1.1.0",
|
||||
"serve-favicon": "2.4.3",
|
||||
"serve-favicon": "2.4.4",
|
||||
"summaly": "2.0.3",
|
||||
"syuilo-password-strength": "0.0.1",
|
||||
"tcp-port-used": "0.1.2",
|
||||
|
@ -1,6 +1,6 @@
|
||||
import * as express from 'express';
|
||||
import App from './models/app';
|
||||
import User from './models/user';
|
||||
import { default as User, IUser } from './models/user';
|
||||
import AccessToken from './models/access-token';
|
||||
import isNativeToken from './common/is-native-token';
|
||||
|
||||
@ -13,10 +13,10 @@ export interface IAuthContext {
|
||||
/**
|
||||
* Authenticated user
|
||||
*/
|
||||
user: any;
|
||||
user: IUser;
|
||||
|
||||
/**
|
||||
* Weather if the request is via the User-Native Token or not
|
||||
* Whether requested with a User-Native Token
|
||||
*/
|
||||
isSecure: boolean;
|
||||
}
|
||||
@ -25,11 +25,15 @@ export default (req: express.Request) => new Promise<IAuthContext>(async (resolv
|
||||
const token = req.body['i'] as string;
|
||||
|
||||
if (token == null) {
|
||||
return resolve({ app: null, user: null, isSecure: false });
|
||||
return resolve({
|
||||
app: null,
|
||||
user: null,
|
||||
isSecure: false
|
||||
});
|
||||
}
|
||||
|
||||
if (isNativeToken(token)) {
|
||||
const user = await User
|
||||
const user: IUser = await User
|
||||
.findOne({ token: token });
|
||||
|
||||
if (user === null) {
|
||||
@ -56,6 +60,10 @@ export default (req: express.Request) => new Promise<IAuthContext>(async (resolv
|
||||
const user = await User
|
||||
.findOne({ _id: accessToken.user_id });
|
||||
|
||||
return resolve({ app: app, user: user, isSecure: false });
|
||||
return resolve({
|
||||
app: app,
|
||||
user: user,
|
||||
isSecure: false
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -37,7 +37,9 @@ export default (
|
||||
data: false
|
||||
} : {
|
||||
data: false,
|
||||
profile: false
|
||||
profile: false,
|
||||
keywords: false,
|
||||
domains: false
|
||||
};
|
||||
|
||||
// Populate the user if 'user' is ID
|
||||
@ -119,6 +121,7 @@ export default (
|
||||
|
||||
if (opts.detail) {
|
||||
if (_user.pinned_post_id) {
|
||||
// Populate pinned post
|
||||
_user.pinned_post = await serializePost(_user.pinned_post_id, meId, {
|
||||
detail: true
|
||||
});
|
||||
|
@ -2,7 +2,7 @@ import * as http from 'http';
|
||||
import * as websocket from 'websocket';
|
||||
import * as redis from 'redis';
|
||||
import config from '../conf';
|
||||
import User from './models/user';
|
||||
import { default as User, IUser } from './models/user';
|
||||
import AccessToken from './models/access-token';
|
||||
import isNativeToken from './common/is-native-token';
|
||||
|
||||
@ -26,7 +26,7 @@ module.exports = (server: http.Server) => {
|
||||
return;
|
||||
}
|
||||
|
||||
const user = await authenticate(connection, request.resourceURL.query.i);
|
||||
const user = await authenticate(request.resourceURL.query.i);
|
||||
|
||||
if (user == null) {
|
||||
connection.send('authentication-failed');
|
||||
@ -56,7 +56,11 @@ module.exports = (server: http.Server) => {
|
||||
});
|
||||
};
|
||||
|
||||
function authenticate(connection: websocket.connection, token: string): Promise<any> {
|
||||
/**
|
||||
* 接続してきたユーザーを取得します
|
||||
* @param token 送信されてきたトークン
|
||||
*/
|
||||
function authenticate(token: string): Promise<IUser> {
|
||||
if (token == null) {
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
@ -64,8 +68,7 @@ function authenticate(connection: websocket.connection, token: string): Promise<
|
||||
return new Promise(async (resolve, reject) => {
|
||||
if (isNativeToken(token)) {
|
||||
// Fetch user
|
||||
// SELECT _id
|
||||
const user = await User
|
||||
const user: IUser = await User
|
||||
.findOne({
|
||||
token: token
|
||||
});
|
||||
@ -81,13 +84,8 @@ function authenticate(connection: websocket.connection, token: string): Promise<
|
||||
}
|
||||
|
||||
// Fetch user
|
||||
// SELECT _id
|
||||
const user = await User
|
||||
.findOne({ _id: accessToken.user_id }, {
|
||||
fields: {
|
||||
_id: true
|
||||
}
|
||||
});
|
||||
const user: IUser = await User
|
||||
.findOne({ _id: accessToken.user_id });
|
||||
|
||||
resolve(user);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user