Merge branch 'develop'

This commit is contained in:
syuilo
2019-04-16 01:24:00 +09:00
10 changed files with 29 additions and 11 deletions

View File

@ -1,4 +1,4 @@
import { Entity, PrimaryColumn, Index, Column, ManyToOne, JoinColumn, RelationId } from 'typeorm';
import { Entity, PrimaryColumn, Index, Column, ManyToOne, JoinColumn } from 'typeorm';
import { User } from './user';
import { App } from './app';
import { id } from '../id';
@ -25,7 +25,8 @@ export class AccessToken {
})
public hash: string;
@RelationId((self: AccessToken) => self.user)
@Index()
@Column(id())
public userId: User['id'];
@ManyToOne(type => User, {

View File

@ -31,7 +31,9 @@ export default async (token: string): Promise<[User | null | undefined, App | nu
.findOne(accessToken.appId);
const user = await Users
.findOne(accessToken.userId);
.findOne({
id: accessToken.userId // findOne(accessToken.userId) のように書かないのは後方互換性のため
});
return [user, app];
}

View File

@ -1,3 +1,3 @@
import rndstr from 'rndstr';
export default () => `0${rndstr('a-zA-Z0-9', 15)}`;
export default () => rndstr('a-zA-Z0-9', 16);

View File

@ -1 +1 @@
export default (token: string) => token.startsWith('0');
export default (token: string) => token.length === 16;

View File

@ -39,7 +39,7 @@ export default define(meta, async (ps, user) => {
}
// Generate access token
const accessToken = '1' + rndstr('a-zA-Z0-9', 15);
const accessToken = rndstr('a-zA-Z0-9', 32);
// Fetch exist access token
const exist = await AccessTokens.findOne({

View File

@ -238,8 +238,6 @@ export default define(meta, async (ps, user, app) => {
userId: user.id
})
))).filter(file => file != null) as DriveFile[];
files = files;
}
let renote: Note | undefined;