From 4275d71a437884a6a8a8fd57e0eab81edcdf683b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eudes=20In=C3=A1cio?= Date: Fri, 10 Jun 2022 09:42:41 +0100 Subject: [PATCH] Refresh token done --- .../chat-options-features.page.ts | 14 +------------- .../modals/set-room-owner/set-room-owner.page.ts | 2 +- src/app/pages/chat/chat.page.ts | 10 +++------- src/app/pages/chat/edit-group/edit-group.page.ts | 6 +----- .../group-contacts/group-contacts.page.ts | 7 +------ .../chat/group-messages/group-messages.page.ts | 7 +------ .../pages/chat/messages/contacts/contacts.page.ts | 7 +------ src/app/pages/chat/messages/messages.page.ts | 7 +------ src/app/pages/chat/new-group/new-group.page.ts | 1 + src/app/shared/chat/edit-group/edit-group.page.ts | 7 +------ .../group-contacts/group-contacts.page.ts | 7 +------ .../chat/group-messages/group-messages.page.ts | 7 +------ .../shared/chat/messages/contacts/contacts.page.ts | 8 ++------ src/app/shared/chat/messages/messages.page.ts | 7 +------ .../popover/chat-popover/chat-popover.page.ts | 8 +------- .../messages-options/messages-options.page.ts | 7 +------ 16 files changed, 19 insertions(+), 93 deletions(-) diff --git a/src/app/modals/chat-options-features/chat-options-features.page.ts b/src/app/modals/chat-options-features/chat-options-features.page.ts index a4a5a91cb..b384af419 100644 --- a/src/app/modals/chat-options-features/chat-options-features.page.ts +++ b/src/app/modals/chat-options-features/chat-options-features.page.ts @@ -48,7 +48,7 @@ export class ChatOptionsFeaturesPage implements OnInit { } ngOnInit() { - + this.chatService.refreshtoken(); } notImplemented() { @@ -118,12 +118,6 @@ export class ChatOptionsFeaturesPage implements OnInit { this.chatService.sendMessage(body).subscribe(res=> { // - },(error: HttpErrorResponse) => { - if(error.status === 401){ - this.chatService.refreshtoken() - this.chatService.sendMessage(body); - } - }); // }; @@ -149,12 +143,6 @@ export class ChatOptionsFeaturesPage implements OnInit { this.chatService.sendMessage(body).subscribe(res=> { - },(error: HttpErrorResponse) => { - if(error.status === 401){ - this.chatService.refreshtoken() - this.chatService.sendMessage(body); - } - }); } diff --git a/src/app/modals/set-room-owner/set-room-owner.page.ts b/src/app/modals/set-room-owner/set-room-owner.page.ts index fd44f44c7..823571f20 100644 --- a/src/app/modals/set-room-owner/set-room-owner.page.ts +++ b/src/app/modals/set-room-owner/set-room-owner.page.ts @@ -33,7 +33,7 @@ export class SetRoomOwnerPage implements OnInit { } ngOnInit() { - + this.chatService.refreshtoken(); } async close(){ diff --git a/src/app/pages/chat/chat.page.ts b/src/app/pages/chat/chat.page.ts index 23608cd60..9c2f930f0 100644 --- a/src/app/pages/chat/chat.page.ts +++ b/src/app/pages/chat/chat.page.ts @@ -133,7 +133,7 @@ export class ChatPage implements OnInit { ngOnInit() { - /* let data = { + /* let data = { status: "success", data: { userId: "CqYSKR5hrAumZihs7", @@ -142,6 +142,8 @@ export class ChatPage implements OnInit { } SessionStore.user.ChatData = data SessionStore.save() */ + console.log(SessionStore.user.ChatData.data.authToken) + this.chatService.refreshtoken(); this.segment = "Contactos"; @@ -517,12 +519,6 @@ export class ChatPage implements OnInit { // }*/ - },(error: HttpErrorResponse) => { - if(error.status === 401){ - this.chatService.refreshtoken() - //this.getChatMembers(); - } - }); } diff --git a/src/app/pages/chat/edit-group/edit-group.page.ts b/src/app/pages/chat/edit-group/edit-group.page.ts index 0a8c3235d..206348eff 100644 --- a/src/app/pages/chat/edit-group/edit-group.page.ts +++ b/src/app/pages/chat/edit-group/edit-group.page.ts @@ -29,6 +29,7 @@ export class EditGroupPage implements OnInit { } ngOnInit() { + this.chatService.refreshtoken(); this.getRoomInfo(); } @@ -37,11 +38,6 @@ export class EditGroupPage implements OnInit { this.room = room['room']; this.groupName = this.room.name.split('-').join(' '); - },(error: HttpErrorResponse) => { - if(error.status === 401) { - this.chatService.refreshtoken(); - this.getRoomInfo() - } }); } diff --git a/src/app/pages/chat/group-messages/group-contacts/group-contacts.page.ts b/src/app/pages/chat/group-messages/group-contacts/group-contacts.page.ts index ca0ff798f..405ce8086 100644 --- a/src/app/pages/chat/group-messages/group-contacts/group-contacts.page.ts +++ b/src/app/pages/chat/group-messages/group-contacts/group-contacts.page.ts @@ -56,6 +56,7 @@ export class GroupContactsPage implements OnInit { } ngOnInit() { + this.chatService.refreshtoken(); this.loadUsers(); this.getMembers(); @@ -85,12 +86,6 @@ export class GroupContactsPage implements OnInit { this.showLoader = false; - },(error: HttpErrorResponse) => { - if(error.status === 401){ - this.chatService.refreshtoken() - this.loadUsers(); - } - }); } diff --git a/src/app/pages/chat/group-messages/group-messages.page.ts b/src/app/pages/chat/group-messages/group-messages.page.ts index 212b2f835..73e60aa79 100644 --- a/src/app/pages/chat/group-messages/group-messages.page.ts +++ b/src/app/pages/chat/group-messages/group-messages.page.ts @@ -133,6 +133,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy { } ngOnInit() { + this.chatService.refreshtoken(); this.loggedUser = this.loggedUserChat; this.getRoomInfo(); @@ -381,12 +382,6 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy { this.allUsers = res['users'].filter(data => data.username != SessionStore.user.UserName); - },(error: HttpErrorResponse) => { - if(error.status === 401){ - this.chatService.refreshtoken() - this.getChatMembers(); - } - }); } diff --git a/src/app/pages/chat/messages/contacts/contacts.page.ts b/src/app/pages/chat/messages/contacts/contacts.page.ts index 40dd5ac8b..0983ecbbe 100644 --- a/src/app/pages/chat/messages/contacts/contacts.page.ts +++ b/src/app/pages/chat/messages/contacts/contacts.page.ts @@ -43,6 +43,7 @@ export class ContactsPage implements OnInit { } ngOnInit() { + this.chatService.refreshtoken(); this.loadUsers(); } @@ -67,12 +68,6 @@ export class ContactsPage implements OnInit { return 0; }); this.showLoader = false; - },(error: HttpErrorResponse) => { - if(error.status === 401){ - this.chatService.refreshtoken() - this.loadUsers(); - } - }); } diff --git a/src/app/pages/chat/messages/messages.page.ts b/src/app/pages/chat/messages/messages.page.ts index 2a26d3274..73062561a 100644 --- a/src/app/pages/chat/messages/messages.page.ts +++ b/src/app/pages/chat/messages/messages.page.ts @@ -157,6 +157,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy { } ngOnInit() { + this.chatService.refreshtoken(); this.wsChatMethodsService.getUserOfRoom(this.roomId).then((value) => { }) @@ -520,12 +521,6 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy { this.members = res['members']; this.dmUsers = res['members'].filter(data => data.username != this.sessionStore.user.UserName) this.showLoader = false; - },(error: HttpErrorResponse) => { - if(error.status === 401){ - this.chatService.refreshtoken() - this.getChatMembers(); - } - }); } diff --git a/src/app/pages/chat/new-group/new-group.page.ts b/src/app/pages/chat/new-group/new-group.page.ts index e1c5889df..6a1760090 100644 --- a/src/app/pages/chat/new-group/new-group.page.ts +++ b/src/app/pages/chat/new-group/new-group.page.ts @@ -43,6 +43,7 @@ export class NewGroupPage implements OnInit { } ngOnInit() { + this.chatService.refreshtoken(); console.log(this.documents) } diff --git a/src/app/shared/chat/edit-group/edit-group.page.ts b/src/app/shared/chat/edit-group/edit-group.page.ts index ac40055f0..dcd9ec80d 100644 --- a/src/app/shared/chat/edit-group/edit-group.page.ts +++ b/src/app/shared/chat/edit-group/edit-group.page.ts @@ -34,6 +34,7 @@ export class EditGroupPage implements OnInit { } ngOnInit() { + this.chatService.refreshtoken(); this.getRoomInfo(); } @@ -42,12 +43,6 @@ export class EditGroupPage implements OnInit { this.room = room['room']; this.groupName = this.room.name.split('-').join(' '); - },(error: HttpErrorResponse) => { - if(error.status === 401){ - this.chatService.refreshtoken() - this.getRoomInfo(); - } - }); } diff --git a/src/app/shared/chat/group-messages/group-contacts/group-contacts.page.ts b/src/app/shared/chat/group-messages/group-contacts/group-contacts.page.ts index 9ff9610f7..d1b369472 100644 --- a/src/app/shared/chat/group-messages/group-contacts/group-contacts.page.ts +++ b/src/app/shared/chat/group-messages/group-contacts/group-contacts.page.ts @@ -57,6 +57,7 @@ export class GroupContactsPage implements OnInit { } ngOnInit() { + this.chatService.refreshtoken(); //this.getRoomInfo(); this.loadUsers(); @@ -203,12 +204,6 @@ export class GroupContactsPage implements OnInit { this.showLoader = false; - },(error: HttpErrorResponse) => { - if(error.status === 401){ - this.chatService.refreshtoken() - this.loadUsers(); - } - }); } diff --git a/src/app/shared/chat/group-messages/group-messages.page.ts b/src/app/shared/chat/group-messages/group-messages.page.ts index da3fa4db9..aef5acf91 100644 --- a/src/app/shared/chat/group-messages/group-messages.page.ts +++ b/src/app/shared/chat/group-messages/group-messages.page.ts @@ -160,6 +160,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe } ngOnInit() { + this.chatService.refreshtoken(); console.log(this.roomId) this.loggedUser = this.loggedUserChat; //setTimeout(() => { @@ -367,12 +368,6 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe this.allUsers = res['users'].filter(data => data.username != SessionStore.user.UserName); // - },(error: HttpErrorResponse) => { - if(error.status === 401){ - this.chatService.refreshtoken() - this.getChatMembers(); - } - }); } diff --git a/src/app/shared/chat/messages/contacts/contacts.page.ts b/src/app/shared/chat/messages/contacts/contacts.page.ts index a0680ce79..cf0821c9b 100644 --- a/src/app/shared/chat/messages/contacts/contacts.page.ts +++ b/src/app/shared/chat/messages/contacts/contacts.page.ts @@ -42,7 +42,9 @@ export class ContactsPage implements OnInit { } ngOnInit() { + this.loadUsers(); + this.chatService.refreshtoken(); } onChange(event){ @@ -83,12 +85,6 @@ export class ContactsPage implements OnInit { return 0; }); this.showLoader = false; - },(error: HttpErrorResponse) => { - if(error.status === 401){ - this.chatService.refreshtoken() - this.loadUsers(); - } - }); } diff --git a/src/app/shared/chat/messages/messages.page.ts b/src/app/shared/chat/messages/messages.page.ts index 10fa2fc1f..ad1a1ac3f 100644 --- a/src/app/shared/chat/messages/messages.page.ts +++ b/src/app/shared/chat/messages/messages.page.ts @@ -155,6 +155,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy } ngOnInit() { + this.chatService.refreshtoken(); this.scrollToBottom(); this.getChatMembers(); @@ -525,12 +526,6 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy this.members = res['members']; this.dmUsers = res['members'].filter(data => data.username != this.sessionStore.user.UserName) this.showLoader = false; - },(error: HttpErrorResponse) => { - if(error.status === 401){ - this.chatService.refreshtoken() - this.getChatMembers(); - } - }); } diff --git a/src/app/shared/popover/chat-popover/chat-popover.page.ts b/src/app/shared/popover/chat-popover/chat-popover.page.ts index cd63e74b9..3e81f382d 100644 --- a/src/app/shared/popover/chat-popover/chat-popover.page.ts +++ b/src/app/shared/popover/chat-popover/chat-popover.page.ts @@ -32,7 +32,7 @@ export class ChatPopoverPage implements OnInit { } ngOnInit() { - + this.chatService.refreshtoken(); } close(action:any){ @@ -169,12 +169,6 @@ export class ChatPopoverPage implements OnInit { }); } - },(error: HttpErrorResponse) => { - if(error.status === 401){ - this.chatService.refreshtoken() - this.deleteGroup(); - } - }); this.popoverController.dismiss('delete'); this.modalController.dismiss('delete'); diff --git a/src/app/shared/popover/messages-options/messages-options.page.ts b/src/app/shared/popover/messages-options/messages-options.page.ts index 744631dd4..7b79121bc 100644 --- a/src/app/shared/popover/messages-options/messages-options.page.ts +++ b/src/app/shared/popover/messages-options/messages-options.page.ts @@ -25,6 +25,7 @@ export class MessagesOptionsPage implements OnInit { } ngOnInit() { + this.chatService.refreshtoken(); } close(){ @@ -42,12 +43,6 @@ export class MessagesOptionsPage implements OnInit { let body = { "roomId": this.roomId } this.chatService.removeChatRoom(body).subscribe(res=>{ - },(error: HttpErrorResponse) => { - if(error.status === 401){ - this.chatService.refreshtoken() - this.closeChatRoom(); - } - }); this.close(); }