Compare commits
No commits in common. "9274be6bb72d62d88d18da91b85066932e91cf3b" and "4e722d9c4751d7070a6a840f577fc3fd37894ba4" have entirely different histories.
9274be6bb7
...
4e722d9c47
@ -1,13 +1,16 @@
|
|||||||
|
import traceback
|
||||||
|
|
||||||
|
from cpl_core.console import Console
|
||||||
|
|
||||||
from bot_api.abc.dto_abc import DtoABC
|
from bot_api.abc.dto_abc import DtoABC
|
||||||
|
|
||||||
|
|
||||||
class TokenDTO(DtoABC):
|
class TokenDTO(DtoABC):
|
||||||
def __init__(self, token: str, refresh_token: str, first_login: bool = False):
|
def __init__(self, token: str, refresh_token: str):
|
||||||
DtoABC.__init__(self)
|
DtoABC.__init__(self)
|
||||||
|
|
||||||
self._token = token
|
self._token = token
|
||||||
self._refresh_token = refresh_token
|
self._refresh_token = refresh_token
|
||||||
self._first_login = first_login
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def token(self) -> str:
|
def token(self) -> str:
|
||||||
@ -17,14 +20,9 @@ class TokenDTO(DtoABC):
|
|||||||
def refresh_token(self) -> str:
|
def refresh_token(self) -> str:
|
||||||
return self._refresh_token
|
return self._refresh_token
|
||||||
|
|
||||||
@property
|
|
||||||
def first_login(self) -> bool:
|
|
||||||
return self._first_login
|
|
||||||
|
|
||||||
def from_dict(self, values: dict):
|
def from_dict(self, values: dict):
|
||||||
self._token = values["token"]
|
self._token = values["token"]
|
||||||
self._refresh_token = values["refreshToken"]
|
self._refresh_token = values["refreshToken"]
|
||||||
self._first_login = values["firstLogin"]
|
|
||||||
|
|
||||||
def to_dict(self) -> dict:
|
def to_dict(self) -> dict:
|
||||||
return {"token": self._token, "refreshToken": self._refresh_token, "firstLogin": self._first_login}
|
return {"token": self._token, "refreshToken": self._refresh_token}
|
||||||
|
@ -480,11 +480,9 @@ class AuthService(AuthServiceABC):
|
|||||||
if user_dto is None:
|
if user_dto is None:
|
||||||
raise ServiceException(ServiceErrorCode.InvalidData, "User not set")
|
raise ServiceException(ServiceErrorCode.InvalidData, "User not set")
|
||||||
|
|
||||||
added_user = False
|
|
||||||
db_user = self._auth_users.find_auth_user_by_email(user_dto.email)
|
db_user = self._auth_users.find_auth_user_by_email(user_dto.email)
|
||||||
if db_user is None:
|
if db_user is None:
|
||||||
self.add_auth_user(user_dto)
|
self.add_auth_user(user_dto)
|
||||||
added_user = True
|
|
||||||
# raise ServiceException(ServiceErrorCode.InvalidUser, f'User not found')
|
# raise ServiceException(ServiceErrorCode.InvalidUser, f'User not found')
|
||||||
|
|
||||||
db_user = self._auth_users.get_auth_user_by_email(user_dto.email)
|
db_user = self._auth_users.get_auth_user_by_email(user_dto.email)
|
||||||
@ -493,7 +491,7 @@ class AuthService(AuthServiceABC):
|
|||||||
lambda x: self._auth_users.add_auth_user_user_rel(AuthUserUsersRelation(db_user, x))
|
lambda x: self._auth_users.add_auth_user_user_rel(AuthUserUsersRelation(db_user, x))
|
||||||
)
|
)
|
||||||
|
|
||||||
if db_user.confirmation_id is not None and not added_user:
|
if db_user.confirmation_id is not None:
|
||||||
raise ServiceException(ServiceErrorCode.Forbidden, "E-Mail not verified")
|
raise ServiceException(ServiceErrorCode.Forbidden, "E-Mail not verified")
|
||||||
|
|
||||||
token = self.generate_token(db_user)
|
token = self.generate_token(db_user)
|
||||||
@ -502,7 +500,7 @@ class AuthService(AuthServiceABC):
|
|||||||
db_user.forgot_password_id = None
|
db_user.forgot_password_id = None
|
||||||
|
|
||||||
self._db.save_changes()
|
self._db.save_changes()
|
||||||
return TokenDTO(token, refresh_token, first_login=added_user)
|
return TokenDTO(token, refresh_token)
|
||||||
|
|
||||||
async def refresh_async(self, token_dto: TokenDTO) -> TokenDTO:
|
async def refresh_async(self, token_dto: TokenDTO) -> TokenDTO:
|
||||||
if token_dto is None:
|
if token_dto is None:
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "kdb-web",
|
"name": "kdb-web",
|
||||||
"version": "1.0.0",
|
"version": "1.0.dev217",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"ng": "ng",
|
"ng": "ng",
|
||||||
"update-version": "ts-node-esm update-version.ts",
|
"update-version": "ts-node-esm update-version.ts",
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
export interface TokenDTO {
|
export interface TokenDTO {
|
||||||
token: string;
|
token: string;
|
||||||
refreshToken: string;
|
refreshToken: string;
|
||||||
firstLogin?: boolean;
|
|
||||||
}
|
}
|
@ -11,8 +11,6 @@ import { AuthUserAtrErrors } from "src/app/models/auth/auth-user-atr-errors";
|
|||||||
import { SpinnerService } from "src/app/services/spinner/spinner.service";
|
import { SpinnerService } from "src/app/services/spinner/spinner.service";
|
||||||
import { ThemeService } from "src/app/services/theme/theme.service";
|
import { ThemeService } from "src/app/services/theme/theme.service";
|
||||||
import { throwError } from "rxjs";
|
import { throwError } from "rxjs";
|
||||||
import { TranslateService } from "@ngx-translate/core";
|
|
||||||
import { ConfirmationDialogService } from "../../../../services/confirmation-dialog/confirmation-dialog.service";
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-login",
|
selector: "app-login",
|
||||||
@ -39,14 +37,11 @@ export class LoginComponent implements OnInit {
|
|||||||
private router: Router,
|
private router: Router,
|
||||||
private spinnerService: SpinnerService,
|
private spinnerService: SpinnerService,
|
||||||
private themeService: ThemeService,
|
private themeService: ThemeService,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute
|
||||||
private confirmDialog: ConfirmationDialogService,
|
|
||||||
private translate: TranslateService
|
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.initLoginForm();
|
|
||||||
this.spinnerService.showSpinner();
|
this.spinnerService.showSpinner();
|
||||||
this.authService.isUserLoggedInAsync().then(result => {
|
this.authService.isUserLoggedInAsync().then(result => {
|
||||||
if (result) {
|
if (result) {
|
||||||
@ -55,6 +50,7 @@ export class LoginComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.checkDiscordLogin();
|
this.checkDiscordLogin();
|
||||||
|
this.initLoginForm();
|
||||||
this.resetStateFlags();
|
this.resetStateFlags();
|
||||||
this.spinnerService.hideSpinner();
|
this.spinnerService.hideSpinner();
|
||||||
});
|
});
|
||||||
@ -82,18 +78,6 @@ export class LoginComponent implements OnInit {
|
|||||||
this.code = "";
|
this.code = "";
|
||||||
return throwError(() => err);
|
return throwError(() => err);
|
||||||
})).subscribe(token => {
|
})).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.authService.saveToken(token);
|
||||||
this.themeService.loadTheme();
|
this.themeService.loadTheme();
|
||||||
this.themeService.loadMenu();
|
this.themeService.loadMenu();
|
||||||
|
@ -84,10 +84,7 @@ export class AutoRolesRulesComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ngOnInit(): void {
|
public ngOnInit(): void {
|
||||||
|
this.data.getServerFromRoute(this.route);
|
||||||
this.setFilterForm();
|
|
||||||
this.data.getServerFromRoute(this.route).then(server => {
|
|
||||||
|
|
||||||
this.spinner.showSpinner();
|
this.spinner.showSpinner();
|
||||||
if (!this.route.snapshot.params["autoRoleId"]) {
|
if (!this.route.snapshot.params["autoRoleId"]) {
|
||||||
this.spinner.hideSpinner();
|
this.spinner.hideSpinner();
|
||||||
@ -99,7 +96,7 @@ export class AutoRolesRulesComponent implements OnInit {
|
|||||||
this.spinner.showSpinner();
|
this.spinner.showSpinner();
|
||||||
this.data.query<SingleDiscordQuery>(Queries.guildsQuery, {
|
this.data.query<SingleDiscordQuery>(Queries.guildsQuery, {
|
||||||
filter: {
|
filter: {
|
||||||
id: server.discordId
|
id: this.sidebar.server$.value?.discordId
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
).subscribe(data => {
|
).subscribe(data => {
|
||||||
@ -114,8 +111,9 @@ export class AutoRolesRulesComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
this.spinner.hideSpinner();
|
this.spinner.hideSpinner();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.setFilterForm();
|
||||||
this.loadNextPage();
|
this.loadNextPage();
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public loadNextPage(): void {
|
public loadNextPage(): void {
|
||||||
|
@ -76,13 +76,12 @@ export class AutoRolesComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ngOnInit(): void {
|
public ngOnInit(): void {
|
||||||
|
this.data.getServerFromRoute(this.route);
|
||||||
|
|
||||||
this.setFilterForm();
|
|
||||||
this.data.getServerFromRoute(this.route).then(server => {
|
|
||||||
this.spinner.showSpinner();
|
this.spinner.showSpinner();
|
||||||
this.data.query<SingleDiscordQuery>(Queries.guildsQuery, {
|
this.data.query<SingleDiscordQuery>(Queries.guildsQuery, {
|
||||||
filter: {
|
filter: {
|
||||||
id: server?.discordId
|
id: this.sidebar.server$.value?.discordId
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
).subscribe(data => {
|
).subscribe(data => {
|
||||||
@ -94,8 +93,9 @@ export class AutoRolesComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
this.spinner.hideSpinner();
|
this.spinner.hideSpinner();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.setFilterForm();
|
||||||
this.loadNextPage();
|
this.loadNextPage();
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public loadNextPage(): void {
|
public loadNextPage(): void {
|
||||||
|
@ -14,6 +14,7 @@ import { LevelListQuery, UserListQuery } from "../../../../models/graphql/query.
|
|||||||
import { DataService } from "../../../../services/data/data.service";
|
import { DataService } from "../../../../services/data/data.service";
|
||||||
import { Page } from "../../../../models/graphql/filter/page.model";
|
import { Page } from "../../../../models/graphql/filter/page.model";
|
||||||
import { Sort, SortDirection } from "../../../../models/graphql/filter/sort.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 { Mutations } from "../../../../models/graphql/mutations.model";
|
||||||
import { throwError } from "rxjs";
|
import { throwError } from "rxjs";
|
||||||
import { UpdateUserMutationResult } from "../../../../models/graphql/result.model";
|
import { UpdateUserMutationResult } from "../../../../models/graphql/result.model";
|
||||||
@ -87,31 +88,32 @@ export class MembersComponent implements OnInit {
|
|||||||
private fb: FormBuilder,
|
private fb: FormBuilder,
|
||||||
private translate: TranslateService,
|
private translate: TranslateService,
|
||||||
private data: DataService,
|
private data: DataService,
|
||||||
|
private sidebar: SidebarService,
|
||||||
private route: ActivatedRoute
|
private route: ActivatedRoute
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.setFilterForm();
|
this.data.getServerFromRoute(this.route);
|
||||||
|
|
||||||
this.data.getServerFromRoute(this.route).then(server => {
|
|
||||||
this.spinner.showSpinner();
|
this.spinner.showSpinner();
|
||||||
this.data.query<LevelListQuery>(Queries.levelQuery, {
|
this.data.query<LevelListQuery>(Queries.levelQuery, {
|
||||||
filter: {
|
filter: {
|
||||||
server: { id: server.id }
|
server: { id: this.sidebar.server$.value?.id }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
).subscribe(data => {
|
).subscribe(data => {
|
||||||
this.levels = data.levels.map(level => {
|
this.levels = data.levels.map(level => {
|
||||||
return { label: level.name, value: level };
|
return { label: level.name, value: level };
|
||||||
});
|
});
|
||||||
|
this.spinner.hideSpinner();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.setFilterForm();
|
||||||
this.loadNextPage();
|
this.loadNextPage();
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loadNextPage() {
|
loadNextPage() {
|
||||||
this.spinner.showSpinner();
|
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
this.data.query<UserListQuery>(Queries.usersQuery, {
|
this.data.query<UserListQuery>(Queries.usersQuery, {
|
||||||
filter: this.filter, page: this.page, sort: this.sort
|
filter: this.filter, page: this.page, sort: this.sort
|
||||||
|
@ -7,6 +7,7 @@ import { DataService } from "../../../../services/data/data.service";
|
|||||||
import { User } from "../../../../models/data/user.model";
|
import { User } from "../../../../models/data/user.model";
|
||||||
import { UserDTO } from "../../../../models/auth/auth-user.dto";
|
import { UserDTO } from "../../../../models/auth/auth-user.dto";
|
||||||
import { AuthService } from "src/app/services/auth/auth.service";
|
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 { ToastService } from "src/app/services/toast/toast.service";
|
||||||
import { TranslateService } from "@ngx-translate/core";
|
import { TranslateService } from "@ngx-translate/core";
|
||||||
|
|
||||||
@ -17,12 +18,13 @@ import { TranslateService } from "@ngx-translate/core";
|
|||||||
})
|
})
|
||||||
export class ProfileComponent implements OnInit {
|
export class ProfileComponent implements OnInit {
|
||||||
|
|
||||||
user: User = { createdAt: "", modifiedAt: "" };
|
user!: User;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private spinner: SpinnerService,
|
private spinner: SpinnerService,
|
||||||
|
private sidebar: SidebarService,
|
||||||
private data: DataService,
|
private data: DataService,
|
||||||
private auth: AuthService,
|
private auth: AuthService,
|
||||||
private toast: ToastService,
|
private toast: ToastService,
|
||||||
@ -30,20 +32,21 @@ export class ProfileComponent implements OnInit {
|
|||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
async ngOnInit() {
|
||||||
this.data.getServerFromRoute(this.route).then(async (server) => {
|
this.data.getServerFromRoute(this.route);
|
||||||
if (!this.route.snapshot.params["memberId"] || this.route.snapshot.params["memberId"] == "undefined") {
|
|
||||||
this.router.navigate([`/server/${server.id}`]);
|
if (!this.route.snapshot.params["memberId"]) {
|
||||||
|
this.router.navigate(["/dashboard"]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let authUser = await this.auth.getLoggedInUser();
|
let authUser = await this.auth.getLoggedInUser();
|
||||||
this.spinner.showSpinner();
|
this.spinner.showSpinner();
|
||||||
let user: UserDTO | null = authUser?.users?.find(u => u.server == server.id) ?? null;
|
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) {
|
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.toast.error(this.translate.instant("view.server.profile.permission_denied"), this.translate.instant("view.server.profile.permission_denied_d"));
|
||||||
this.spinner.hideSpinner();
|
this.spinner.hideSpinner();
|
||||||
this.router.navigate(["/server", server.id]);
|
this.router.navigate(["/server", this.sidebar.server$.value?.id]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,8 +62,5 @@ export class ProfileComponent implements OnInit {
|
|||||||
this.user = user;
|
this.user = user;
|
||||||
this.spinner.hideSpinner();
|
this.spinner.hideSpinner();
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,9 +25,7 @@ export class ServerDashboardComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.data.getServerFromRoute(this.route).then(server => {
|
this.data.getServerFromRoute(this.route);
|
||||||
this.server = server;
|
|
||||||
});
|
|
||||||
|
|
||||||
this.sidebar.server$.subscribe(server => {
|
this.sidebar.server$.subscribe(server => {
|
||||||
if (!server) {
|
if (!server) {
|
||||||
|
@ -19,7 +19,7 @@ import { DiscordAuthURL } from "../../models/auth/discord-auth-url.dto";
|
|||||||
import { OAuthDTO } from "../../models/auth/oauth.dto";
|
import { OAuthDTO } from "../../models/auth/oauth.dto";
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: "root"
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class AuthService {
|
export class AuthService {
|
||||||
|
|
||||||
@ -42,15 +42,14 @@ export class AuthService {
|
|||||||
getAllUsers(): Observable<Array<AuthUserDTO>> {
|
getAllUsers(): Observable<Array<AuthUserDTO>> {
|
||||||
return this.http.get<Array<AuthUserDTO>>(`${this.appsettings.getApiURL()}/api/auth/users`, {
|
return this.http.get<Array<AuthUserDTO>>(`${this.appsettings.getApiURL()}/api/auth/users`, {
|
||||||
headers: new HttpHeaders({
|
headers: new HttpHeaders({
|
||||||
"Content-Type": "application/json"
|
'Content-Type': 'application/json'
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getFilteredUsers(selectCriterions: AuthUserSelectCriterion): Observable<GetFilteredAuthUsersResultDTO> {
|
getFilteredUsers(selectCriterions: AuthUserSelectCriterion): Observable<GetFilteredAuthUsersResultDTO> {
|
||||||
return this.http.post<GetFilteredAuthUsersResultDTO>(`${this.appsettings.getApiURL()}/api/auth/users/get/filtered`, selectCriterions, {
|
return this.http.post<GetFilteredAuthUsersResultDTO>(`${this.appsettings.getApiURL()}/api/auth/users/get/filtered`, selectCriterions, {
|
||||||
headers: new HttpHeaders({
|
headers: new HttpHeaders({
|
||||||
"Content-Type": "application/json"
|
'Content-Type': 'application/json'
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -58,7 +57,7 @@ export class AuthService {
|
|||||||
getUserByEMail(email: string): Observable<AuthUserDTO> {
|
getUserByEMail(email: string): Observable<AuthUserDTO> {
|
||||||
return this.http.get<AuthUserDTO>(`${this.appsettings.getApiURL()}/api/auth/users/get/${email}`, {
|
return this.http.get<AuthUserDTO>(`${this.appsettings.getApiURL()}/api/auth/users/get/${email}`, {
|
||||||
headers: new HttpHeaders({
|
headers: new HttpHeaders({
|
||||||
"Content-Type": "application/json"
|
'Content-Type': 'application/json'
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -66,7 +65,7 @@ export class AuthService {
|
|||||||
findUserByEMail(email: string): Observable<AuthUserDTO> {
|
findUserByEMail(email: string): Observable<AuthUserDTO> {
|
||||||
return this.http.get<AuthUserDTO>(`${this.appsettings.getApiURL()}/api/auth/users/find/${email}`, {
|
return this.http.get<AuthUserDTO>(`${this.appsettings.getApiURL()}/api/auth/users/find/${email}`, {
|
||||||
headers: new HttpHeaders({
|
headers: new HttpHeaders({
|
||||||
"Content-Type": "application/json"
|
'Content-Type': 'application/json'
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -75,7 +74,7 @@ export class AuthService {
|
|||||||
register(user: AuthUserDTO): Observable<unknown> {
|
register(user: AuthUserDTO): Observable<unknown> {
|
||||||
return this.http.post<TokenDTO>(`${this.appsettings.getApiURL()}/api/auth/register`, user, {
|
return this.http.post<TokenDTO>(`${this.appsettings.getApiURL()}/api/auth/register`, user, {
|
||||||
headers: new HttpHeaders({
|
headers: new HttpHeaders({
|
||||||
"Content-Type": "application/json"
|
'Content-Type': 'application/json'
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -83,7 +82,7 @@ export class AuthService {
|
|||||||
confirmEMail(id: string): Observable<boolean> {
|
confirmEMail(id: string): Observable<boolean> {
|
||||||
return this.http.post<boolean>(`${this.appsettings.getApiURL()}/api/auth/register-by-id/${id}`, {
|
return this.http.post<boolean>(`${this.appsettings.getApiURL()}/api/auth/register-by-id/${id}`, {
|
||||||
headers: new HttpHeaders({
|
headers: new HttpHeaders({
|
||||||
"Content-Type": "application/json"
|
'Content-Type': 'application/json'
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -91,7 +90,7 @@ export class AuthService {
|
|||||||
login(user: AuthUserDTO): Observable<TokenDTO> {
|
login(user: AuthUserDTO): Observable<TokenDTO> {
|
||||||
return this.http.post<TokenDTO>(`${this.appsettings.getApiURL()}/api/auth/login`, user, {
|
return this.http.post<TokenDTO>(`${this.appsettings.getApiURL()}/api/auth/login`, user, {
|
||||||
headers: new HttpHeaders({
|
headers: new HttpHeaders({
|
||||||
"Content-Type": "application/json"
|
'Content-Type': 'application/json'
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -99,7 +98,7 @@ export class AuthService {
|
|||||||
verifyLogin(): Observable<boolean> {
|
verifyLogin(): Observable<boolean> {
|
||||||
return this.http.get<boolean>(`${this.appsettings.getApiURL()}/api/auth/verify-login`, {
|
return this.http.get<boolean>(`${this.appsettings.getApiURL()}/api/auth/verify-login`, {
|
||||||
headers: new HttpHeaders({
|
headers: new HttpHeaders({
|
||||||
"Content-Type": "application/json"
|
'Content-Type': 'application/json'
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -107,7 +106,7 @@ export class AuthService {
|
|||||||
forgotPassword(email: string): Observable<unknown> {
|
forgotPassword(email: string): Observable<unknown> {
|
||||||
return this.http.post(`${this.appsettings.getApiURL()}/api/auth/forgot-password/${email}`, {
|
return this.http.post(`${this.appsettings.getApiURL()}/api/auth/forgot-password/${email}`, {
|
||||||
headers: new HttpHeaders({
|
headers: new HttpHeaders({
|
||||||
"Content-Type": "application/json"
|
'Content-Type': 'application/json'
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -115,7 +114,7 @@ export class AuthService {
|
|||||||
getEMailFromforgotPasswordId(id: string): Observable<EMailStringDTO> {
|
getEMailFromforgotPasswordId(id: string): Observable<EMailStringDTO> {
|
||||||
return this.http.post<EMailStringDTO>(`${this.appsettings.getApiURL()}/api/auth/confirm-forgot-password/${id}`, {
|
return this.http.post<EMailStringDTO>(`${this.appsettings.getApiURL()}/api/auth/confirm-forgot-password/${id}`, {
|
||||||
headers: new HttpHeaders({
|
headers: new HttpHeaders({
|
||||||
"Content-Type": "application/json"
|
'Content-Type': 'application/json'
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -123,7 +122,7 @@ export class AuthService {
|
|||||||
resetPassword(resetPasswordDTO: ResetPasswordDTO): Observable<unknown> {
|
resetPassword(resetPasswordDTO: ResetPasswordDTO): Observable<unknown> {
|
||||||
return this.http.post(`${this.appsettings.getApiURL()}/api/auth/reset-password`, resetPasswordDTO, {
|
return this.http.post(`${this.appsettings.getApiURL()}/api/auth/reset-password`, resetPasswordDTO, {
|
||||||
headers: new HttpHeaders({
|
headers: new HttpHeaders({
|
||||||
"Content-Type": "application/json"
|
'Content-Type': 'application/json'
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -131,7 +130,7 @@ export class AuthService {
|
|||||||
updateUser(updateUserDTO: UpdateUserDTO): Observable<unknown> {
|
updateUser(updateUserDTO: UpdateUserDTO): Observable<unknown> {
|
||||||
return this.http.post(`${this.appsettings.getApiURL()}/api/auth/update-user`, updateUserDTO, {
|
return this.http.post(`${this.appsettings.getApiURL()}/api/auth/update-user`, updateUserDTO, {
|
||||||
headers: new HttpHeaders({
|
headers: new HttpHeaders({
|
||||||
"Content-Type": "application/json"
|
'Content-Type': 'application/json'
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -139,7 +138,7 @@ export class AuthService {
|
|||||||
updateUserAsAdmin(updateUserDTO: AdminUpdateUserDTO): Observable<unknown> {
|
updateUserAsAdmin(updateUserDTO: AdminUpdateUserDTO): Observable<unknown> {
|
||||||
return this.http.post(`${this.appsettings.getApiURL()}/api/auth/update-user-as-admin`, updateUserDTO, {
|
return this.http.post(`${this.appsettings.getApiURL()}/api/auth/update-user-as-admin`, updateUserDTO, {
|
||||||
headers: new HttpHeaders({
|
headers: new HttpHeaders({
|
||||||
"Content-Type": "application/json"
|
'Content-Type': 'application/json'
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -147,7 +146,7 @@ export class AuthService {
|
|||||||
refresh(token: TokenDTO): Observable<TokenDTO> {
|
refresh(token: TokenDTO): Observable<TokenDTO> {
|
||||||
return this.http.post<TokenDTO>(`${this.appsettings.getApiURL()}/api/auth/refresh`, token, {
|
return this.http.post<TokenDTO>(`${this.appsettings.getApiURL()}/api/auth/refresh`, token, {
|
||||||
headers: new HttpHeaders({
|
headers: new HttpHeaders({
|
||||||
"Content-Type": "application/json"
|
'Content-Type': 'application/json'
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -155,7 +154,7 @@ export class AuthService {
|
|||||||
deleteUserByMail(mail: string) {
|
deleteUserByMail(mail: string) {
|
||||||
return this.http.post(`${this.appsettings.getApiURL()}/api/auth/delete-user-by-mail/${mail}`, {
|
return this.http.post(`${this.appsettings.getApiURL()}/api/auth/delete-user-by-mail/${mail}`, {
|
||||||
headers: new HttpHeaders({
|
headers: new HttpHeaders({
|
||||||
"Content-Type": "application/json"
|
'Content-Type': 'application/json'
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -164,7 +163,7 @@ export class AuthService {
|
|||||||
getDiscordAuthURL() {
|
getDiscordAuthURL() {
|
||||||
return this.http.get<DiscordAuthURL>(`${this.appsettings.getApiURL()}/api/auth/discord/get-url`, {
|
return this.http.get<DiscordAuthURL>(`${this.appsettings.getApiURL()}/api/auth/discord/get-url`, {
|
||||||
headers: new HttpHeaders({
|
headers: new HttpHeaders({
|
||||||
"Content-Type": "application/json"
|
'Content-Type': 'application/json'
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -172,7 +171,7 @@ export class AuthService {
|
|||||||
discordLogin(code: string, state: string): Observable<TokenDTO> {
|
discordLogin(code: string, state: string): Observable<TokenDTO> {
|
||||||
return this.http.get<TokenDTO>(`${this.appsettings.getApiURL()}/api/auth/discord/login?code=${code}&state=${state}`, {
|
return this.http.get<TokenDTO>(`${this.appsettings.getApiURL()}/api/auth/discord/login?code=${code}&state=${state}`, {
|
||||||
headers: new HttpHeaders({
|
headers: new HttpHeaders({
|
||||||
"Content-Type": "application/json"
|
'Content-Type': 'application/json'
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -181,7 +180,7 @@ export class AuthService {
|
|||||||
discordRegister(oAuthDTO: OAuthDTO) {
|
discordRegister(oAuthDTO: OAuthDTO) {
|
||||||
return this.http.post(`${this.appsettings.getApiURL()}/api/auth/discord/register`, oAuthDTO, {
|
return this.http.post(`${this.appsettings.getApiURL()}/api/auth/discord/register`, oAuthDTO, {
|
||||||
headers: new HttpHeaders({
|
headers: new HttpHeaders({
|
||||||
"Content-Type": "application/json"
|
'Content-Type': 'application/json'
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -196,25 +195,21 @@ export class AuthService {
|
|||||||
|
|
||||||
/* utils */
|
/* utils */
|
||||||
saveToken(token: TokenDTO): void {
|
saveToken(token: TokenDTO): void {
|
||||||
localStorage.setItem("jwt", token.token);
|
localStorage.setItem('jwt', token.token);
|
||||||
localStorage.setItem("rjwt", token.refreshToken);
|
localStorage.setItem('rjwt', token.refreshToken);
|
||||||
if (this.router.url.startsWith("/auth")) {
|
if (this.router.url.startsWith('/auth')) {
|
||||||
this.router.navigate(["/dashboard"]);
|
this.router.navigate(['/dashboard']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getToken(): TokenDTO {
|
getToken(): TokenDTO {
|
||||||
return {
|
return {
|
||||||
token: localStorage.getItem("jwt") ?? "",
|
token: localStorage.getItem('jwt') ?? '',
|
||||||
refreshToken: localStorage.getItem("rjwt") ?? ""
|
refreshToken: localStorage.getItem('rjwt') ?? ''
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
getDecodedToken(token: TokenDTO | undefined = undefined): { [key: string]: any } | null {
|
getDecodedToken(): { [key: string]: any } | null{
|
||||||
if (token) {
|
|
||||||
return this.jwtHelper.decodeToken(token.token);
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.jwtHelper.decodeToken(this.getToken().token);
|
return this.jwtHelper.decodeToken(this.getToken().token);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,26 +219,26 @@ export class AuthService {
|
|||||||
if (token && token.token && token.refreshToken) {
|
if (token && token.token && token.refreshToken) {
|
||||||
return this.http.post<TokenDTO>(`${this.appsettings.getApiURL()}/api/auth/revoke`, token, {
|
return this.http.post<TokenDTO>(`${this.appsettings.getApiURL()}/api/auth/revoke`, token, {
|
||||||
headers: new HttpHeaders({
|
headers: new HttpHeaders({
|
||||||
"Content-Type": "application/json"
|
'Content-Type': 'application/json'
|
||||||
})
|
})
|
||||||
}).pipe(catchError((error: any) => {
|
}).pipe(catchError((error: any) => {
|
||||||
error.error = null;
|
error.error = null;
|
||||||
this.isLoggedIn$.next(false);
|
this.isLoggedIn$.next(false);
|
||||||
localStorage.removeItem("rjwt");
|
localStorage.removeItem('rjwt');
|
||||||
this.router.navigate(["/auth/login"]);
|
this.router.navigate(['/auth/login']);
|
||||||
throw error;
|
throw error;
|
||||||
})).subscribe(() => {
|
})).subscribe(() => {
|
||||||
this.isLoggedIn$.next(false);
|
this.isLoggedIn$.next(false);
|
||||||
localStorage.removeItem("jwt");
|
localStorage.removeItem('jwt');
|
||||||
localStorage.removeItem("rjwt");
|
localStorage.removeItem('rjwt');
|
||||||
this.router.navigate(["/auth/login"]);
|
this.router.navigate(['/auth/login']);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.isLoggedIn$.next(false);
|
this.isLoggedIn$.next(false);
|
||||||
localStorage.removeItem("rjwt");
|
localStorage.removeItem('rjwt');
|
||||||
this.router.navigate(["/auth/login"]);
|
this.router.navigate(['/auth/login']);
|
||||||
|
|
||||||
return null;
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
async getLoggedInUser(): Promise<AuthUserDTO | null> {
|
async getLoggedInUser(): Promise<AuthUserDTO | null> {
|
||||||
@ -300,13 +295,13 @@ export class AuthService {
|
|||||||
}
|
}
|
||||||
const token = this.getDecodedToken();
|
const token = this.getDecodedToken();
|
||||||
if (!token) return false;
|
if (!token) return false;
|
||||||
return AuthRoles[token["role"]] === AuthRoles[role];
|
return AuthRoles[token['role']] === AuthRoles[role];
|
||||||
}
|
}
|
||||||
|
|
||||||
getEMailFromDecodedToken(token: { [key: string]: any } | null): string | null {
|
getEMailFromDecodedToken(token: { [key: string]: any } | null): string | null {
|
||||||
if (!token) {
|
if (!token) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return token["email"];
|
return token['email'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,13 +25,12 @@ export class DataService {
|
|||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public getServerFromRoute(route: ActivatedRoute): Promise<Server> {
|
public getServerFromRoute(route: ActivatedRoute) {
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
this.spinner.showSpinner();
|
this.spinner.showSpinner();
|
||||||
if (!route.snapshot.params["serverId"]) {
|
if (!route.snapshot.params["serverId"]) {
|
||||||
this.spinner.hideSpinner();
|
this.spinner.hideSpinner();
|
||||||
this.router.navigate(["/dashboard"]);
|
this.router.navigate(["/dashboard"]);
|
||||||
reject();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.query<Server>(Queries.serversQuery, {
|
this.query<Server>(Queries.serversQuery, {
|
||||||
@ -43,10 +42,7 @@ export class DataService {
|
|||||||
).subscribe(server => {
|
).subscribe(server => {
|
||||||
this.sidebar.setServer(server);
|
this.sidebar.setServer(server);
|
||||||
this.spinner.hideSpinner();
|
this.spinner.hideSpinner();
|
||||||
resolve(server);
|
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public query<T>(query: string, variables?: Variables, f?: Function): Observable<T> {
|
public query<T>(query: string, variables?: Variables, f?: Function): Observable<T> {
|
||||||
@ -57,7 +53,7 @@ export class DataService {
|
|||||||
})
|
})
|
||||||
.pipe(map(d => {
|
.pipe(map(d => {
|
||||||
if (d.errors && d.errors.length > 0) {
|
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;
|
return d.data;
|
||||||
}))
|
}))
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
"WebVersion": {
|
"WebVersion": {
|
||||||
"Major": "1",
|
"Major": "1",
|
||||||
"Minor": "0",
|
"Minor": "0",
|
||||||
"Micro": "0"
|
"Micro": "dev217"
|
||||||
},
|
},
|
||||||
"Themes": [
|
"Themes": [
|
||||||
{
|
{
|
||||||
|
@ -106,11 +106,7 @@
|
|||||||
"user_not_found": "Benutzer nicht gefunden",
|
"user_not_found": "Benutzer nicht gefunden",
|
||||||
"e_mail_not_confirmed": "E-Mail nicht bestätigt",
|
"e_mail_not_confirmed": "E-Mail nicht bestätigt",
|
||||||
"password_required": "Passwort benö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": {
|
"register": {
|
||||||
"first_name": "Vorname",
|
"first_name": "Vorname",
|
||||||
|
Loading…
Reference in New Issue
Block a user