summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2019-04-16 01:24:00 +0900
committersyuilo <syuilotan@yahoo.co.jp>2019-04-16 01:24:00 +0900
commitc6cef0162ddb5013a7753deb93e358f825b2b349 (patch)
tree52edff22e989b64a4973f9786ddd901108442b74 /src
parentMerge branch 'develop' (diff)
parent11.1.3 (diff)
downloadmisskey-c6cef0162ddb5013a7753deb93e358f825b2b349.tar.gz
misskey-c6cef0162ddb5013a7753deb93e358f825b2b349.tar.bz2
misskey-c6cef0162ddb5013a7753deb93e358f825b2b349.zip
Merge branch 'develop'
Diffstat (limited to 'src')
-rw-r--r--src/models/entities/access-token.ts5
-rw-r--r--src/server/api/authenticate.ts4
-rw-r--r--src/server/api/common/generate-native-user-token.ts2
-rw-r--r--src/server/api/common/is-native-token.ts2
-rw-r--r--src/server/api/endpoints/auth/accept.ts2
-rw-r--r--src/server/api/endpoints/notes/create.ts2
6 files changed, 9 insertions, 8 deletions
diff --git a/src/models/entities/access-token.ts b/src/models/entities/access-token.ts
index d08930cf5a..137bf1444d 100644
--- a/src/models/entities/access-token.ts
+++ b/src/models/entities/access-token.ts
@@ -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, {
diff --git a/src/server/api/authenticate.ts b/src/server/api/authenticate.ts
index ecf4a82c45..519ed77388 100644
--- a/src/server/api/authenticate.ts
+++ b/src/server/api/authenticate.ts
@@ -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];
}
diff --git a/src/server/api/common/generate-native-user-token.ts b/src/server/api/common/generate-native-user-token.ts
index 9d44885630..a372221a0a 100644
--- a/src/server/api/common/generate-native-user-token.ts
+++ b/src/server/api/common/generate-native-user-token.ts
@@ -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);
diff --git a/src/server/api/common/is-native-token.ts b/src/server/api/common/is-native-token.ts
index 22af84aad2..2833c570c8 100644
--- a/src/server/api/common/is-native-token.ts
+++ b/src/server/api/common/is-native-token.ts
@@ -1 +1 @@
-export default (token: string) => token.startsWith('0');
+export default (token: string) => token.length === 16;
diff --git a/src/server/api/endpoints/auth/accept.ts b/src/server/api/endpoints/auth/accept.ts
index a584e7267b..be7f3b5468 100644
--- a/src/server/api/endpoints/auth/accept.ts
+++ b/src/server/api/endpoints/auth/accept.ts
@@ -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({
diff --git a/src/server/api/endpoints/notes/create.ts b/src/server/api/endpoints/notes/create.ts
index 83649015d8..994dfb4dca 100644
--- a/src/server/api/endpoints/notes/create.ts
+++ b/src/server/api/endpoints/notes/create.ts
@@ -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;