Enhance session and profile handling with validation and error handling improvements
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
class User {
|
||||
constructor(info){
|
||||
if(!info || !info.userid) throw "Can not construct empty profile";
|
||||
if(!info || !info.userid) throw new Error("Cannot construct empty profile");
|
||||
this.userid = info.userid;
|
||||
this.profile = {
|
||||
firstName: info.profile && info.profile.firstName || '',
|
||||
lastName: info.profile && info.profile.lastName || '',
|
||||
photo: info.profile && info.profile.photo || '',
|
||||
location: info.profile && info.profile.location || 'USA',
|
||||
language: info.profile && info.profile.language || 'en',
|
||||
status: info.profile && info.profile.status || '',
|
||||
description: info.profile && info.profile.description || '',
|
||||
firstName: info.profile?.firstName || '',
|
||||
lastName: info.profile?.lastName || '',
|
||||
photo: info.profile?.photo || '',
|
||||
location: info.profile?.location || 'USA',
|
||||
language: info.profile?.language || 'en',
|
||||
status: info.profile?.status || '',
|
||||
description: info.profile?.description || '',
|
||||
};
|
||||
this.data = info.data || {};
|
||||
this.username = info.username || '';
|
||||
@@ -23,8 +23,8 @@ class User {
|
||||
this.isCourse = info.isCourse || false;
|
||||
this.isPrivate = info.isPrivate || false;
|
||||
this.isChat = info.isChat || false;
|
||||
this.subscribed = info.subscribed || {}; //Subscribed user to groups
|
||||
this.pending = info.pending || {}; //Private groups require authorization
|
||||
this.subscribed = JSON.parse(JSON.stringify(info.subscribed || {})); //Subscribed user to groups
|
||||
this.pending = JSON.parse(JSON.stringify(info.pending || {})); //Private groups require authorization
|
||||
}
|
||||
|
||||
toObj(){
|
||||
|
||||
Reference in New Issue
Block a user