Announcement

Collapse
No announcement yet.

Email with espocrm entryPoint link login problems

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Email with espocrm entryPoint link login problems

    Hello,

    I have a link in an email like this:

    http://{espoURL}/?entryPoint=pdf&entityType={myEntityType}&entityId ={myEntityId}&templateId={myTemplateId}


    The behavior i'm seeing is that:

    Scenario 1: I have already logged into espo in my browser window and then click the link in the email
    Result - The document loads in my browser with no login needed

    Scenario 2: I paste the link directly into my browser in a new 'Private' (ie. incognito window)
    Result - an apache login screen is displayed and even if I put in the correct username and password i just displays the same screen after hitting submit

    Is Scenario 2 expected ? Please see below screenshot for what I'm seeing.

    What I would have expected is perhaps the Espo login screen to appear and after logging in that would re-direct me to the pdf ?




    Attached Files
    Last edited by czcpf; 08-23-2023, 03:00 AM.

  • #2
    I came across this thread which posted a similar question.

    Hi, I have a question regarding the download of documents. If I offer a file for download via this link: ..../?entryPoint=download&id= When you click, a window from Espo appears in which you are prompted to enter a user name and password. Is there a possibility that the user has to enter his own login data there? (Upload


    shalmaxb suggests using a custom entrypoint plugin has anyone used this?

    The extension created by devcrm.it to EspoCRM. The extension let you share files with your clients. - dubas-pro/ext-public-attachment

    Comment


    • #3
      > What I would have expected is perhaps the Espo login screen to appear and after logging in that would re-direct me to the pdf ?

      It's not supposed that you share the link. The purpose of the link is that it's opened from within the UI. It downloads the file, it does not render the UI.

      You don't need an entry point for your case. You need a frontend view (route + controller + view) that will redirect to entry point. That will establish the login form.

      Comment


      • yuri
        yuri commented
        Editing a comment
        And it's not the apache login. It's the Basic Authentication which the Espo frontend uses to communicate with the backend. https://en.wikipedia.org/wiki/Basic_...authentication The browser renders it because the backend sends a specific header.

        It should download the file once you entered correct username/password. It does work for PDF (tested). Might be some configuration issue.

      • czcpf
        czcpf commented
        Editing a comment
        Thank you. I have looked into your suggestion and it is almost complete. I will post back a complete example for others once I finish.
        Last edited by czcpf; 08-23-2023, 08:39 PM.

    • #4
      UPDATE WITH EXAMPLE

      Thanks to yuri for getting me started on this. Below is an example of how I was able to achieve the desired effect.


      custom/Espo/Custom/Resources/metadata/clientDefs/{MyCustomEntity}.json

      Code:
      {
      "controller": "custom:controllers/{my-custom-entity}",
          "boolFilterList": [
               "onlyMy"
           ],​
      }
      client/custom/src/controllers/{my-custom-entity}.js

      Code:
      define('custom:controllers/{my-custom-entity}', ['controllers/record'], function (Dep) {
      
          return Dep.extend({
      
              actionViewDetailedReport: function (options) {
      
                  if (!options.entryPoint || !options.entityType || !options.entityId || !options.templateId) {
                      throw new Espo.Exceptions.NotFound();
                  }
                  let entryPoint = options.entryPoint;
                  let entityType = options.entityType;
                  let entityId = options.entityId;
                  let templateId = options.templateId;
      
                  let redirectUrl = `/?entryPoint=${entryPoint}&entityType=${entityType}&entityId=${entityId}&templateId=${templateId}` ;
                  window.location.href = redirectUrl;
                  return;
              },
          });
      });​
      A url such as
      http://{espoSiteUrl}/#{MyCustomEntity}/viewDetailedReport?entryPoint=pdf&entityType={MyCu stomEntity}&entityId={entityId}&templateId={templa teId}

      will:
      Scenario 1: user is already logged into Espo in browser
      Result: load the entryPoint url (in this case it is a pdf template)

      Scenario 2: user is not logged into Espo in browser (ie. incognito/private)
      Result: Espo login window is shown, after successful login the user is redirected to the entryPoint and (in this case, the document is displayed)






      Comment

      Working...
      X