diff --git a/kdb-bot/src/bot_api/model/token_dto.py b/kdb-bot/src/bot_api/model/token_dto.py index d4a73f2f..88ff8501 100644 --- a/kdb-bot/src/bot_api/model/token_dto.py +++ b/kdb-bot/src/bot_api/model/token_dto.py @@ -1,16 +1,13 @@ -import traceback - -from cpl_core.console import Console - from bot_api.abc.dto_abc import DtoABC class TokenDTO(DtoABC): - def __init__(self, token: str, refresh_token: str): + def __init__(self, token: str, refresh_token: str, first_login: bool = False): DtoABC.__init__(self) self._token = token self._refresh_token = refresh_token + self._first_login = first_login @property def token(self) -> str: @@ -20,9 +17,14 @@ class TokenDTO(DtoABC): def refresh_token(self) -> str: return self._refresh_token + @property + def first_login(self) -> bool: + return self._first_login + def from_dict(self, values: dict): self._token = values["token"] self._refresh_token = values["refreshToken"] + self._first_login = values["firstLogin"] def to_dict(self) -> dict: - return {"token": self._token, "refreshToken": self._refresh_token} + return {"token": self._token, "refreshToken": self._refresh_token, "firstLogin": self._first_login} diff --git a/kdb-bot/src/bot_api/service/auth_service.py b/kdb-bot/src/bot_api/service/auth_service.py index b7dda916..bd386490 100644 --- a/kdb-bot/src/bot_api/service/auth_service.py +++ b/kdb-bot/src/bot_api/service/auth_service.py @@ -480,9 +480,11 @@ class AuthService(AuthServiceABC): if user_dto is None: raise ServiceException(ServiceErrorCode.InvalidData, "User not set") + added_user = False db_user = self._auth_users.find_auth_user_by_email(user_dto.email) if db_user is None: self.add_auth_user(user_dto) + added_user = True # raise ServiceException(ServiceErrorCode.InvalidUser, f'User not found') db_user = self._auth_users.get_auth_user_by_email(user_dto.email) @@ -491,7 +493,7 @@ class AuthService(AuthServiceABC): lambda x: self._auth_users.add_auth_user_user_rel(AuthUserUsersRelation(db_user, x)) ) - if db_user.confirmation_id is not None: + if db_user.confirmation_id is not None and not added_user: raise ServiceException(ServiceErrorCode.Forbidden, "E-Mail not verified") token = self.generate_token(db_user) @@ -500,7 +502,7 @@ class AuthService(AuthServiceABC): db_user.forgot_password_id = None self._db.save_changes() - return TokenDTO(token, refresh_token) + return TokenDTO(token, refresh_token, first_login=added_user) async def refresh_async(self, token_dto: TokenDTO) -> TokenDTO: if token_dto is None: diff --git a/kdb-web/package.json b/kdb-web/package.json index 80c20063..13ddc1d0 100644 --- a/kdb-web/package.json +++ b/kdb-web/package.json @@ -1,6 +1,6 @@ { "name": "kdb-web", - "version": "1.0.dev217", + "version": "1.0.0", "scripts": { "ng": "ng", "update-version": "ts-node-esm update-version.ts", diff --git a/kdb-web/src/app/models/auth/token.dto.ts b/kdb-web/src/app/models/auth/token.dto.ts index 10e8b7c4..69f452e6 100644 --- a/kdb-web/src/app/models/auth/token.dto.ts +++ b/kdb-web/src/app/models/auth/token.dto.ts @@ -1,4 +1,5 @@ export interface TokenDTO { token: string; refreshToken: string; -} \ No newline at end of file + firstLogin?: boolean; +} diff --git a/kdb-web/src/app/modules/auth/components/login/login.component.ts b/kdb-web/src/app/modules/auth/components/login/login.component.ts index 0d4cdf6e..d6d5d6a6 100644 --- a/kdb-web/src/app/modules/auth/components/login/login.component.ts +++ b/kdb-web/src/app/modules/auth/components/login/login.component.ts @@ -11,6 +11,8 @@ import { AuthUserAtrErrors } from "src/app/models/auth/auth-user-atr-errors"; import { SpinnerService } from "src/app/services/spinner/spinner.service"; import { ThemeService } from "src/app/services/theme/theme.service"; import { throwError } from "rxjs"; +import { TranslateService } from "@ngx-translate/core"; +import { ConfirmationDialogService } from "../../../../services/confirmation-dialog/confirmation-dialog.service"; @Component({ selector: "app-login", @@ -37,11 +39,14 @@ export class LoginComponent implements OnInit { private router: Router, private spinnerService: SpinnerService, private themeService: ThemeService, - private route: ActivatedRoute + private route: ActivatedRoute, + private confirmDialog: ConfirmationDialogService, + private translate: TranslateService ) { } ngOnInit(): void { + this.initLoginForm(); this.spinnerService.showSpinner(); this.authService.isUserLoggedInAsync().then(result => { if (result) { @@ -50,7 +55,6 @@ export class LoginComponent implements OnInit { } this.checkDiscordLogin(); - this.initLoginForm(); this.resetStateFlags(); this.spinnerService.hideSpinner(); }); @@ -78,6 +82,18 @@ export class LoginComponent implements OnInit { this.code = ""; return throwError(() => err); })).subscribe(token => { + if (token.firstLogin) { + console.log(1, this.authService.getEMailFromDecodedToken(this.authService.getDecodedToken(token))) + this.confirmDialog.confirmDialog( + this.translate.instant( + "auth.login.message.confirm_email"), + this.translate.instant( + "auth.login.message.confirm_email_d", + { email: this.authService.getEMailFromDecodedToken(this.authService.getDecodedToken(token)) } + ) + ); + } + this.authService.saveToken(token); this.themeService.loadTheme(); this.themeService.loadMenu(); diff --git a/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.ts b/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.ts index 383586a2..2b6a0251 100644 --- a/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.ts +++ b/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.ts @@ -84,36 +84,38 @@ export class AutoRolesRulesComponent implements OnInit { } public ngOnInit(): void { - this.data.getServerFromRoute(this.route); - this.spinner.showSpinner(); - if (!this.route.snapshot.params["autoRoleId"]) { - this.spinner.hideSpinner(); - this.router.navigate(["../"]); - return; - } - this.autoRoleId = +this.route.snapshot.params["autoRoleId"]; - - this.spinner.showSpinner(); - this.data.query(Queries.guildsQuery, { - filter: { - id: this.sidebar.server$.value?.discordId - } - } - ).subscribe(data => { - this.guild = data.guilds[0]; - this.emojis = this.guild.emojis - .map(x => { - return { label: x.name, value: x }; - }); - this.roles = this.guild.roles - .map(x => { - return { label: x.name, value: x }; - }); - this.spinner.hideSpinner(); - }); this.setFilterForm(); - this.loadNextPage(); + this.data.getServerFromRoute(this.route).then(server => { + + this.spinner.showSpinner(); + if (!this.route.snapshot.params["autoRoleId"]) { + this.spinner.hideSpinner(); + this.router.navigate(["../"]); + return; + } + this.autoRoleId = +this.route.snapshot.params["autoRoleId"]; + + this.spinner.showSpinner(); + this.data.query(Queries.guildsQuery, { + filter: { + id: server.discordId + } + } + ).subscribe(data => { + this.guild = data.guilds[0]; + this.emojis = this.guild.emojis + .map(x => { + return { label: x.name, value: x }; + }); + this.roles = this.guild.roles + .map(x => { + return { label: x.name, value: x }; + }); + this.spinner.hideSpinner(); + }); + this.loadNextPage(); + }); } public loadNextPage(): void { diff --git a/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.ts b/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.ts index 78b27de9..03d6b2f8 100644 --- a/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.ts +++ b/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.ts @@ -76,26 +76,26 @@ export class AutoRolesComponent implements OnInit { } public ngOnInit(): void { - this.data.getServerFromRoute(this.route); - - this.spinner.showSpinner(); - this.data.query(Queries.guildsQuery, { - filter: { - id: this.sidebar.server$.value?.discordId - } - } - ).subscribe(data => { - this.guild = data.guilds[0]; - this.channels = this.guild.channels - .filter(x => x.type === ChannelType.text) - .map(x => { - return { label: x.name, value: x }; - }); - this.spinner.hideSpinner(); - }); this.setFilterForm(); - this.loadNextPage(); + this.data.getServerFromRoute(this.route).then(server => { + this.spinner.showSpinner(); + this.data.query(Queries.guildsQuery, { + filter: { + id: server?.discordId + } + } + ).subscribe(data => { + this.guild = data.guilds[0]; + this.channels = this.guild.channels + .filter(x => x.type === ChannelType.text) + .map(x => { + return { label: x.name, value: x }; + }); + this.spinner.hideSpinner(); + }); + this.loadNextPage(); + }); } public loadNextPage(): void { diff --git a/kdb-web/src/app/modules/view/server/members/members.component.ts b/kdb-web/src/app/modules/view/server/members/members.component.ts index 51bf7cba..19ddeebe 100644 --- a/kdb-web/src/app/modules/view/server/members/members.component.ts +++ b/kdb-web/src/app/modules/view/server/members/members.component.ts @@ -14,7 +14,6 @@ import { LevelListQuery, UserListQuery } from "../../../../models/graphql/query. import { DataService } from "../../../../services/data/data.service"; import { Page } from "../../../../models/graphql/filter/page.model"; import { Sort, SortDirection } from "../../../../models/graphql/filter/sort.model"; -import { SidebarService } from "../../../../services/sidebar/sidebar.service"; import { Mutations } from "../../../../models/graphql/mutations.model"; import { throwError } from "rxjs"; import { UpdateUserMutationResult } from "../../../../models/graphql/result.model"; @@ -88,32 +87,31 @@ export class MembersComponent implements OnInit { private fb: FormBuilder, private translate: TranslateService, private data: DataService, - private sidebar: SidebarService, private route: ActivatedRoute ) { } ngOnInit(): void { - this.data.getServerFromRoute(this.route); - - this.spinner.showSpinner(); - this.data.query(Queries.levelQuery, { - filter: { - server: { id: this.sidebar.server$.value?.id } - } - } - ).subscribe(data => { - this.levels = data.levels.map(level => { - return { label: level.name, value: level }; - }); - this.spinner.hideSpinner(); - }); - this.setFilterForm(); - this.loadNextPage(); + + this.data.getServerFromRoute(this.route).then(server => { + this.spinner.showSpinner(); + this.data.query(Queries.levelQuery, { + filter: { + server: { id: server.id } + } + } + ).subscribe(data => { + this.levels = data.levels.map(level => { + return { label: level.name, value: level }; + }); + }); + this.loadNextPage(); + }); } loadNextPage() { + this.spinner.showSpinner(); this.loading = true; this.data.query(Queries.usersQuery, { filter: this.filter, page: this.page, sort: this.sort diff --git a/kdb-web/src/app/modules/view/server/profile/profile.component.ts b/kdb-web/src/app/modules/view/server/profile/profile.component.ts index eb67181b..80909967 100644 --- a/kdb-web/src/app/modules/view/server/profile/profile.component.ts +++ b/kdb-web/src/app/modules/view/server/profile/profile.component.ts @@ -7,7 +7,6 @@ import { DataService } from "../../../../services/data/data.service"; import { User } from "../../../../models/data/user.model"; import { UserDTO } from "../../../../models/auth/auth-user.dto"; import { AuthService } from "src/app/services/auth/auth.service"; -import { SidebarService } from "../../../../services/sidebar/sidebar.service"; import { ToastService } from "src/app/services/toast/toast.service"; import { TranslateService } from "@ngx-translate/core"; @@ -18,13 +17,12 @@ import { TranslateService } from "@ngx-translate/core"; }) export class ProfileComponent implements OnInit { - user!: User; + user: User = { createdAt: "", modifiedAt: "" }; constructor( private route: ActivatedRoute, private router: Router, private spinner: SpinnerService, - private sidebar: SidebarService, private data: DataService, private auth: AuthService, private toast: ToastService, @@ -32,35 +30,37 @@ export class ProfileComponent implements OnInit { ) { } - async ngOnInit() { - this.data.getServerFromRoute(this.route); - - if (!this.route.snapshot.params["memberId"]) { - this.router.navigate(["/dashboard"]); - return; - } - - let authUser = await this.auth.getLoggedInUser(); - this.spinner.showSpinner(); - let user: UserDTO | null = authUser?.users?.find(u => u.server == this.sidebar.server$.value?.id) ?? null; - if (!user || user?.id != this.route.snapshot.params["memberId"] && !user?.isModerator) { - this.toast.error(this.translate.instant("view.server.profile.permission_denied"), this.translate.instant("view.server.profile.permission_denied_d")); - this.spinner.hideSpinner(); - this.router.navigate(["/server", this.sidebar.server$.value?.id]); - return; - } - - this.data.query(Queries.singleUserQuery, { - filter: { - id: this.route.snapshot.params["memberId"] - } - }, - function(data: UserListQuery) { - return data.users.length > 0 ? data.users[0] : null; + ngOnInit() { + this.data.getServerFromRoute(this.route).then(async (server) => { + if (!this.route.snapshot.params["memberId"] || this.route.snapshot.params["memberId"] == "undefined") { + this.router.navigate([`/server/${server.id}`]); + return; } - ).subscribe(user => { - this.user = user; - this.spinner.hideSpinner(); + + let authUser = await this.auth.getLoggedInUser(); + this.spinner.showSpinner(); + let user: UserDTO | null = authUser?.users?.find(u => u.server == server.id) ?? null; + if (!user || user?.id != this.route.snapshot.params["memberId"] && !user?.isModerator) { + this.toast.error(this.translate.instant("view.server.profile.permission_denied"), this.translate.instant("view.server.profile.permission_denied_d")); + this.spinner.hideSpinner(); + this.router.navigate(["/server", server.id]); + return; + } + + this.data.query(Queries.singleUserQuery, { + filter: { + id: this.route.snapshot.params["memberId"] + } + }, + function(data: UserListQuery) { + return data.users.length > 0 ? data.users[0] : null; + } + ).subscribe(user => { + this.user = user; + this.spinner.hideSpinner(); + }); }); + + } } diff --git a/kdb-web/src/app/modules/view/server/server-dashboard/server-dashboard.component.ts b/kdb-web/src/app/modules/view/server/server-dashboard/server-dashboard.component.ts index 651b8d56..642e0f7c 100644 --- a/kdb-web/src/app/modules/view/server/server-dashboard/server-dashboard.component.ts +++ b/kdb-web/src/app/modules/view/server/server-dashboard/server-dashboard.component.ts @@ -25,7 +25,9 @@ export class ServerDashboardComponent implements OnInit { } ngOnInit(): void { - this.data.getServerFromRoute(this.route); + this.data.getServerFromRoute(this.route).then(server => { + this.server = server; + }); this.sidebar.server$.subscribe(server => { if (!server) { diff --git a/kdb-web/src/app/services/auth/auth.service.ts b/kdb-web/src/app/services/auth/auth.service.ts index 73686887..2c41f9f2 100644 --- a/kdb-web/src/app/services/auth/auth.service.ts +++ b/kdb-web/src/app/services/auth/auth.service.ts @@ -19,7 +19,7 @@ import { DiscordAuthURL } from "../../models/auth/discord-auth-url.dto"; import { OAuthDTO } from "../../models/auth/oauth.dto"; @Injectable({ - providedIn: 'root' + providedIn: "root" }) export class AuthService { @@ -42,14 +42,15 @@ export class AuthService { getAllUsers(): Observable> { return this.http.get>(`${this.appsettings.getApiURL()}/api/auth/users`, { headers: new HttpHeaders({ - 'Content-Type': 'application/json' + "Content-Type": "application/json" }) }); } + getFilteredUsers(selectCriterions: AuthUserSelectCriterion): Observable { return this.http.post(`${this.appsettings.getApiURL()}/api/auth/users/get/filtered`, selectCriterions, { headers: new HttpHeaders({ - 'Content-Type': 'application/json' + "Content-Type": "application/json" }) }); } @@ -57,7 +58,7 @@ export class AuthService { getUserByEMail(email: string): Observable { return this.http.get(`${this.appsettings.getApiURL()}/api/auth/users/get/${email}`, { headers: new HttpHeaders({ - 'Content-Type': 'application/json' + "Content-Type": "application/json" }) }); } @@ -65,7 +66,7 @@ export class AuthService { findUserByEMail(email: string): Observable { return this.http.get(`${this.appsettings.getApiURL()}/api/auth/users/find/${email}`, { headers: new HttpHeaders({ - 'Content-Type': 'application/json' + "Content-Type": "application/json" }) }); } @@ -74,7 +75,7 @@ export class AuthService { register(user: AuthUserDTO): Observable { return this.http.post(`${this.appsettings.getApiURL()}/api/auth/register`, user, { headers: new HttpHeaders({ - 'Content-Type': 'application/json' + "Content-Type": "application/json" }) }); } @@ -82,7 +83,7 @@ export class AuthService { confirmEMail(id: string): Observable { return this.http.post(`${this.appsettings.getApiURL()}/api/auth/register-by-id/${id}`, { headers: new HttpHeaders({ - 'Content-Type': 'application/json' + "Content-Type": "application/json" }) }); } @@ -90,7 +91,7 @@ export class AuthService { login(user: AuthUserDTO): Observable { return this.http.post(`${this.appsettings.getApiURL()}/api/auth/login`, user, { headers: new HttpHeaders({ - 'Content-Type': 'application/json' + "Content-Type": "application/json" }) }); } @@ -98,7 +99,7 @@ export class AuthService { verifyLogin(): Observable { return this.http.get(`${this.appsettings.getApiURL()}/api/auth/verify-login`, { headers: new HttpHeaders({ - 'Content-Type': 'application/json' + "Content-Type": "application/json" }) }); } @@ -106,7 +107,7 @@ export class AuthService { forgotPassword(email: string): Observable { return this.http.post(`${this.appsettings.getApiURL()}/api/auth/forgot-password/${email}`, { headers: new HttpHeaders({ - 'Content-Type': 'application/json' + "Content-Type": "application/json" }) }); } @@ -114,7 +115,7 @@ export class AuthService { getEMailFromforgotPasswordId(id: string): Observable { return this.http.post(`${this.appsettings.getApiURL()}/api/auth/confirm-forgot-password/${id}`, { headers: new HttpHeaders({ - 'Content-Type': 'application/json' + "Content-Type": "application/json" }) }); } @@ -122,7 +123,7 @@ export class AuthService { resetPassword(resetPasswordDTO: ResetPasswordDTO): Observable { return this.http.post(`${this.appsettings.getApiURL()}/api/auth/reset-password`, resetPasswordDTO, { headers: new HttpHeaders({ - 'Content-Type': 'application/json' + "Content-Type": "application/json" }) }); } @@ -130,7 +131,7 @@ export class AuthService { updateUser(updateUserDTO: UpdateUserDTO): Observable { return this.http.post(`${this.appsettings.getApiURL()}/api/auth/update-user`, updateUserDTO, { headers: new HttpHeaders({ - 'Content-Type': 'application/json' + "Content-Type": "application/json" }) }); } @@ -138,7 +139,7 @@ export class AuthService { updateUserAsAdmin(updateUserDTO: AdminUpdateUserDTO): Observable { return this.http.post(`${this.appsettings.getApiURL()}/api/auth/update-user-as-admin`, updateUserDTO, { headers: new HttpHeaders({ - 'Content-Type': 'application/json' + "Content-Type": "application/json" }) }); } @@ -146,7 +147,7 @@ export class AuthService { refresh(token: TokenDTO): Observable { return this.http.post(`${this.appsettings.getApiURL()}/api/auth/refresh`, token, { headers: new HttpHeaders({ - 'Content-Type': 'application/json' + "Content-Type": "application/json" }) }); } @@ -154,7 +155,7 @@ export class AuthService { deleteUserByMail(mail: string) { return this.http.post(`${this.appsettings.getApiURL()}/api/auth/delete-user-by-mail/${mail}`, { headers: new HttpHeaders({ - 'Content-Type': 'application/json' + "Content-Type": "application/json" }) }); } @@ -163,7 +164,7 @@ export class AuthService { getDiscordAuthURL() { return this.http.get(`${this.appsettings.getApiURL()}/api/auth/discord/get-url`, { headers: new HttpHeaders({ - 'Content-Type': 'application/json' + "Content-Type": "application/json" }) }); } @@ -171,7 +172,7 @@ export class AuthService { discordLogin(code: string, state: string): Observable { return this.http.get(`${this.appsettings.getApiURL()}/api/auth/discord/login?code=${code}&state=${state}`, { headers: new HttpHeaders({ - 'Content-Type': 'application/json' + "Content-Type": "application/json" }) }); } @@ -180,7 +181,7 @@ export class AuthService { discordRegister(oAuthDTO: OAuthDTO) { return this.http.post(`${this.appsettings.getApiURL()}/api/auth/discord/register`, oAuthDTO, { headers: new HttpHeaders({ - 'Content-Type': 'application/json' + "Content-Type": "application/json" }) }); } @@ -195,21 +196,25 @@ export class AuthService { /* utils */ saveToken(token: TokenDTO): void { - localStorage.setItem('jwt', token.token); - localStorage.setItem('rjwt', token.refreshToken); - if (this.router.url.startsWith('/auth')) { - this.router.navigate(['/dashboard']); + localStorage.setItem("jwt", token.token); + localStorage.setItem("rjwt", token.refreshToken); + if (this.router.url.startsWith("/auth")) { + this.router.navigate(["/dashboard"]); } } getToken(): TokenDTO { return { - token: localStorage.getItem('jwt') ?? '', - refreshToken: localStorage.getItem('rjwt') ?? '' + token: localStorage.getItem("jwt") ?? "", + refreshToken: localStorage.getItem("rjwt") ?? "" }; } - getDecodedToken(): { [key: string]: any } | null{ + getDecodedToken(token: TokenDTO | undefined = undefined): { [key: string]: any } | null { + if (token) { + return this.jwtHelper.decodeToken(token.token); + } + return this.jwtHelper.decodeToken(this.getToken().token); } @@ -219,26 +224,26 @@ export class AuthService { if (token && token.token && token.refreshToken) { return this.http.post(`${this.appsettings.getApiURL()}/api/auth/revoke`, token, { headers: new HttpHeaders({ - 'Content-Type': 'application/json' + "Content-Type": "application/json" }) }).pipe(catchError((error: any) => { error.error = null; this.isLoggedIn$.next(false); - localStorage.removeItem('rjwt'); - this.router.navigate(['/auth/login']); + localStorage.removeItem("rjwt"); + this.router.navigate(["/auth/login"]); throw error; })).subscribe(() => { this.isLoggedIn$.next(false); - localStorage.removeItem('jwt'); - localStorage.removeItem('rjwt'); - this.router.navigate(['/auth/login']); + localStorage.removeItem("jwt"); + localStorage.removeItem("rjwt"); + this.router.navigate(["/auth/login"]); }); } this.isLoggedIn$.next(false); - localStorage.removeItem('rjwt'); - this.router.navigate(['/auth/login']); + localStorage.removeItem("rjwt"); + this.router.navigate(["/auth/login"]); - return null + return null; } async getLoggedInUser(): Promise { @@ -295,13 +300,13 @@ export class AuthService { } const token = this.getDecodedToken(); if (!token) return false; - return AuthRoles[token['role']] === AuthRoles[role]; + return AuthRoles[token["role"]] === AuthRoles[role]; } getEMailFromDecodedToken(token: { [key: string]: any } | null): string | null { if (!token) { return null; } - return token['email']; + return token["email"]; } } diff --git a/kdb-web/src/app/services/data/data.service.ts b/kdb-web/src/app/services/data/data.service.ts index fbcb7c45..6112d96e 100644 --- a/kdb-web/src/app/services/data/data.service.ts +++ b/kdb-web/src/app/services/data/data.service.ts @@ -25,24 +25,28 @@ export class DataService { ) { } - public getServerFromRoute(route: ActivatedRoute) { - this.spinner.showSpinner(); - if (!route.snapshot.params["serverId"]) { - this.spinner.hideSpinner(); - this.router.navigate(["/dashboard"]); - return; - } - - this.query(Queries.serversQuery, { - filter: { id: route.snapshot.params["serverId"] } - }, - function(data: Query) { - return data.servers.length > 0 ? data.servers[0] : null; + public getServerFromRoute(route: ActivatedRoute): Promise { + return new Promise((resolve, reject) => { + this.spinner.showSpinner(); + if (!route.snapshot.params["serverId"]) { + this.spinner.hideSpinner(); + this.router.navigate(["/dashboard"]); + reject(); } - ).subscribe(server => { - this.sidebar.setServer(server); - this.spinner.hideSpinner(); + + this.query(Queries.serversQuery, { + filter: { id: route.snapshot.params["serverId"] } + }, + function(data: Query) { + return data.servers.length > 0 ? data.servers[0] : null; + } + ).subscribe(server => { + this.sidebar.setServer(server); + this.spinner.hideSpinner(); + resolve(server); + }); }); + } public query(query: string, variables?: Variables, f?: Function): Observable { @@ -53,7 +57,7 @@ export class DataService { }) .pipe(map(d => { if (d.errors && d.errors.length > 0) { - throw new Error(d.errors.map((x: {message: String}) => x.message).toString()); + throw new Error(d.errors.map((x: { message: String }) => x.message).toString()); } return d.data; })) diff --git a/kdb-web/src/assets/config.json b/kdb-web/src/assets/config.json index e129a65a..c055d5cb 100644 --- a/kdb-web/src/assets/config.json +++ b/kdb-web/src/assets/config.json @@ -3,7 +3,7 @@ "WebVersion": { "Major": "1", "Minor": "0", - "Micro": "dev217" + "Micro": "0" }, "Themes": [ { @@ -23,4 +23,4 @@ "Name": "sh-edraft-dark-theme" } ] -} +} \ No newline at end of file diff --git a/kdb-web/src/assets/i18n/de.json b/kdb-web/src/assets/i18n/de.json index 8a7b7eaf..53632ad2 100644 --- a/kdb-web/src/assets/i18n/de.json +++ b/kdb-web/src/assets/i18n/de.json @@ -106,7 +106,11 @@ "user_not_found": "Benutzer nicht gefunden", "e_mail_not_confirmed": "E-Mail nicht bestätigt", "password_required": "Passwort benötigt", - "wrong_password": "Falsches passwort" + "wrong_password": "Falsches passwort", + "message": { + "confirm_email": "E-Mail Bestätigen", + "confirm_email_d": "Du musst deine E-Mail {{email}} Bestätigen, in dem du den Link öffnest, den wir dir geschickt haben." + } }, "register": { "first_name": "Vorname",