diff options
author | crupest <crupest@outlook.com> | 2020-08-08 18:12:30 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-08-08 18:12:30 +0800 |
commit | 178c90085502e916102f3ecf9c2e2cc38cdb441e (patch) | |
tree | 766b335421212d96f8a047148ac43603604cceea | |
parent | 9d421cf555774e437f156347c0502170f475c544 (diff) | |
download | timeline-178c90085502e916102f3ecf9c2e2cc38cdb441e.tar.gz timeline-178c90085502e916102f3ecf9c2e2cc38cdb441e.tar.bz2 timeline-178c90085502e916102f3ecf9c2e2cc38cdb441e.zip |
[front] Add unique if to user in http and implement mock server.
-rw-r--r-- | Timeline/ClientApp/src/app/http/mock/user.ts | 10 | ||||
-rw-r--r-- | Timeline/ClientApp/src/app/http/user.ts | 1 |
2 files changed, 10 insertions, 1 deletions
diff --git a/Timeline/ClientApp/src/app/http/mock/user.ts b/Timeline/ClientApp/src/app/http/mock/user.ts index d16302d4..53f68b5a 100644 --- a/Timeline/ClientApp/src/app/http/mock/user.ts +++ b/Timeline/ClientApp/src/app/http/mock/user.ts @@ -43,7 +43,9 @@ export class MockUserNotExistError extends Error { }
}
-export function checkUsername(username: string): void {
+export function checkUsername(
+ username: string
+): asserts username is 'user' | 'admin' {
if (!['user', 'admin'].includes(username)) throw new MockUserNotExistError();
}
@@ -54,6 +56,11 @@ export function checkToken(token: string): string { return token.substr(6);
}
+const uniqueIdMap = {
+ user: 'e4c80127d092d9b2fc19c5e04612d4c0',
+ admin: '5640fa45435f9a55077b9f77c42a77bb',
+};
+
export async function getUser(
username: 'user' | 'admin' | string
): Promise<HttpUser> {
@@ -62,6 +69,7 @@ export async function getUser( `user.${username}.nickname`
);
return {
+ uniqueId: uniqueIdMap[username],
username: username,
nickname:
savedNickname == null || savedNickname === '' ? username : savedNickname,
diff --git a/Timeline/ClientApp/src/app/http/user.ts b/Timeline/ClientApp/src/app/http/user.ts index 345a5e8b..8d5e8a0b 100644 --- a/Timeline/ClientApp/src/app/http/user.ts +++ b/Timeline/ClientApp/src/app/http/user.ts @@ -12,6 +12,7 @@ import { } from './common';
export interface HttpUser {
+ uniqueId: string;
username: string;
administrator: boolean;
nickname: string;
|