Custom Login Method

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • item
    Active Community Member
    • Mar 2017
    • 1531

    #1

    Custom Login Method

    Hi,
    i try a new "method" for login ..
    - back-end receive the request and process and find User and return the User.
    - front-end : data is OK, and contain all info/preference of User

    but i think : this.triggerLogin(null, data); is my issue or headers
    so it "catch(xhr" ... but all is empty.

    Can someone help ?


    PHP Code:

     
    const authString btoa('**top:' topBase64);
                        
    headers = {  
                            
    'Authorization''Basic ' authString,  
                            
    'Espo-Authorization'authString,  
                            
    'Espo-Authorization-Create-Token-Secret''true',  
                            
    'X-TOP-Authentication''true'  
                        
    };


    Espo.Ajax.getRequest('App/user'null, {  
                        
    logintrue,  
                        
    headersheaders  
                    
    }).then(data => {  
                        
    Espo.Ui.notify(false);
                        
    console.log('Authentication response:'data);  
                        
    Espo.Ui.notify(false);
                        
    this.triggerLogin(nulldata);   // <---- Problem here for me
                    
    }).catch(xhr => {  

                        
    console.log('Full error details:', {  
                            
    statusxhr.status,  
                            
    statusTextxhr.statusText,  
                            
    responseTextxhr.responseText,  
                            
    responseJSONxhr.responseJSON  
                        
    });

                        if (
    xhr.status === 401) {  
                            
    Espo.Ui.warning('Authentication failed');  
                        } else {  
                            
    Espo.Ui.warning('Error occurred during login');  
                        }  
                    });
    ​ 

    PHP Code:

    {user: {}, acl: {}, preferences: {}, token'4e77a275fa0fd8ad9b864229fc74a087'settings: {}, }
    acl
    :
    {
    table: {}, fieldTable: {}, assignmentPermission'all'messagePermission'all'mentionPermission'all'}
    appParams
    :
    {
    maxUploadSize64isRestrictedModefalsepasswordChangeForNonAdminDisabledtruetimeZoneList: Array(2), auth2FARequiredfalse}
    language
    :
    "en_US"
    preferences
    :
    {
    id'6435fb32a5ce98d96'timeZonenulldateFormatnulltimeFormatnullweekStart: -1}
    settings
    :
    {
    systemUserAttributes: {}, useCachefalse}
    token
    :
    "4e77a275fa0fd8ad9b864229fc74a087"
    user
    :
    {
    id'1234fb32a5ce98d96'name'Demo'deletedfalseuserName'demo'type'regular'…​ 
    If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​
Working...