Skip to content
This repository was archived by the owner on Aug 17, 2021. It is now read-only.
This repository was archived by the owner on Aug 17, 2021. It is now read-only.

Site key cannot be dynamic #219

@ITachiLab

Description

@ITachiLab

Even though I can pass a scope value to the key attribute in the vc-recaptcha directive, it is initialized only once, right after the recaptcha widget is created. This is enough for cases, where the key is static and hardcoded. Currently I am dealing with a site, which retrieves the site key from an external source. When the key is finally retrieved (by the $http service), the initialization process is already finished and the site key bound to the widget cannot be modified anymore.

I have dived into the code and localized the core of my headaches:

// Remove this listener to avoid creating the widget more than once.
removeCreationListener();

It is not bad, because we do not want an another watcher hanging in memory forever, but it destroys the possibility of modifying the site key.

I have created a solution which accepts both string and promise as a key. The recaptcha widget is not initialized until the promise is resolved, thus we are free to pass the key when it is available.

It works very well, so I think I can share with it in a pull request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions