Skip to content
  1. Extras
  2. HybridAuth
  3. Snippets
  4. HybridAuth

HybridAuth

Snippet outputs formula for authorization on the site.

Parameters

NameDefault valueDescription
&activeProviderTpltpl.HybridAuth.provider.activechunk to output icons of a bound service.
&addContextsadditional contexts, separated by commas. E.g. &addContexts=`web,ru,en`
&groupslist of groups to register the user, separated by commas. User role can be indicated in the group with colon. E.g. &groups=Users:1 will add user to group "Users" with role "member".
&loginContextcurrent contextmain context for authorization. On default – current.
&loginResourceId0identifier of a resource on which user should be sent after end of the session. On default 0 renews the current page.
&loginTpltpl.HybridAuth.loginthis chunk will be pointed to an anonymous user, i.e. to any guest.
&logoutResourceId0resource identifier, where a user is sent after the end of the session. On default, 0 updates a current page.
&logoutTpltpl.HybridAuth.logoutthis chunk will be shown to an anonymous user.
&providerTpltpl.HybridAuth.providerchunk to output links for authorization, or binding of server to the account.
&providersall availablelist of providers for authorization, separated by commas. All available providers are here {core_path}components/hybridauth/model/hybridauth/lib/Providers/. For example, &providers=Google,Twitter,Facebook.
&rememberme1remembers users for a long time.

Samples

Snippet should be activated uncached, because it outputs different chunks depending on users authorization.

On usual activation snippet will output all providers registered in the system.

modx
[[!HybridAuth]]

They can be limited indicating them as a list, separated by commas:

modx
[[!HybridAuth?
  &providers=`Yandex,Google,Twitter,Facebook,Vkontakte`
]]

Authorization in 2 contexts at once:

modx
[[!HybridAuth?
  &providers=`Yandex,Google`
  &loginContext=`web`
  &addContexts=`en`
]]

Provider settings

Individual system setting with prefix ha.keys. is indicated for every provider of authorization:

Provider settings

Value of setting is JSON array which content depends on the provider.

E.g. id and secret should be indicated for Google, but for Twitter – key and secret.

That is why pay attention to the settings which will be given to you during registration.

Keys from providers need to be derived to work of the component, and it is not understandable at once where you should look for them. That’s is why there are some main links:

Contexts

If you have several individual contexts on the website, you can authorize them through the same providers, but for different domains.

For this you need to indicate keys directly in settings of the context, but not in general settings of the system.

For proper work of snippet it is better to include friendly url.