@@ -3,6 +3,7 @@ import { NavController } from "@ionic/angular";
33import { Storage } from "@ionic/storage" ;
44
55import { ApiService } from "../../api/api.service" ;
6+ import { UserDto } from "../account/account.dto" ;
67import { AccountService } from "../account/account.service" ;
78import { ProjectService } from "../project/project.service" ;
89
@@ -34,7 +35,7 @@ export class AuthService {
3435 // eslint-disable-next-line no-useless-catch
3536 try {
3637 const result = await this . api . post < any > (
37- this . api . getAccountApiUrl ( ) + "/jwt" ,
38+ this . api . getAccountApiUrlV1 ( ) + "/jwt" ,
3839 {
3940 email,
4041 password,
@@ -46,15 +47,16 @@ export class AuthService {
4647
4748 await this . storage . set ( "jwt" , result ) ;
4849
49- const data = await this . api . get < any > (
50- this . api . getAccountApiUrl ( ) + "/users/" + result . jwt . issuer
50+ const data = await this . api . get < UserDto > (
51+ this . api . getAccountApiUrlV2 ( ) + "/users/" + result . jwt . issuer
5152 ) ;
52- await this . storage . set ( "user" , data . user ) ;
53+
54+ await this . storage . set ( "user" , data ) ;
5355
5456 const currentOrganization =
55- data . user . organizations . find (
56- ( organization ) => organization . role_name === "owner"
57- ) || data . user . organizations [ 0 ] ;
57+ data . organizations . find (
58+ ( organization ) => organization . is_owner === true
59+ ) || data . organizations [ 0 ] ;
5860 await this . storage . set ( "currentOrganization" , currentOrganization . id ) ;
5961
6062 await this . projectService . setDefaultProject ( currentOrganization . id ) ;
@@ -67,7 +69,7 @@ export class AuthService {
6769 console . log ( "LOGGING OUT" ) ;
6870 const token = await this . storage . get ( "jwt" ) ;
6971 await this . api . delete < any > (
70- this . api . getAccountApiUrl ( ) + "/jwt /" + token . jwt . jti
72+ this . api . getIAMApiUrl ( ) + "/jwts /" + token . jwt . jti
7173 ) ;
7274 await this . storage . clear ( ) ;
7375 await this . navCtrl . navigateRoot ( [ "/login" ] ) ;
0 commit comments