{"id":13805279,"url":"https://github.com/calinrada/PhalconUserPlugin","last_synced_at":"2025-05-13T19:30:34.877Z","repository":{"id":10511496,"uuid":"12698820","full_name":"calinrada/PhalconUserPlugin","owner":"calinrada","description":null,"archived":false,"fork":false,"pushed_at":"2023-09-07T18:56:47.000Z","size":355,"stargazers_count":184,"open_issues_count":8,"forks_count":68,"subscribers_count":32,"default_branch":"master","last_synced_at":"2025-02-21T05:07:00.484Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/calinrada.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2013-09-09T10:28:15.000Z","updated_at":"2025-01-03T11:55:03.000Z","dependencies_parsed_at":"2024-01-03T02:24:37.187Z","dependency_job_id":"7cce3874-91f7-40e8-9184-5697be57ffcf","html_url":"https://github.com/calinrada/PhalconUserPlugin","commit_stats":{"total_commits":116,"total_committers":13,"mean_commits":8.923076923076923,"dds":0.5517241379310345,"last_synced_commit":"82e7d06d53db80808f710e7ffeadb9e4b3b89a46"},"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/calinrada%2FPhalconUserPlugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/calinrada%2FPhalconUserPlugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/calinrada%2FPhalconUserPlugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/calinrada%2FPhalconUserPlugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/calinrada","download_url":"https://codeload.github.com/calinrada/PhalconUserPlugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254012927,"owners_count":21999335,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T01:00:59.567Z","updated_at":"2025-05-13T19:30:34.494Z","avatar_url":"https://github.com/calinrada.png","language":"PHP","funding_links":[],"categories":["ACL"],"sub_categories":[],"readme":"# IMPORATNT! You should switch to branch v3.0.0\n\nWe have switched to facebook/graph-sdk 5.4 !\n\n```bash\n$ composer require crada/phalcon-user-plugin:^3.0\n```\n\n# Phalcon User Plugin (v 2.0)\n\n* [About](#about)\n* [Features](#features)\n* [Installation](#installation)\n* [Plug it](#plug-it)\n* [Configuration](#configuration)\n* [Example controller](#example-controller)\n* [Known issues](#known-issues)\n* [Examples](#examples)\n* [TODO](#todo)\n\n### \u003ca id=\"about\"\u003e\u003c/a\u003eAbout\n\nThis is a plugin based on Vokuro ACL idea.\n    \n### \u003ca id=\"features\"\u003e\u003c/a\u003eFeatures\n\n- Login / Register with Facebook account\n- Login / Register with LinkedIn account\n- Login / Register with Twitter account\n- Login / Register with Google account\n- Change password\n- Password recovery by email\n- Protect different areas from your website, where a user must be logged in, in order to have access\n- Protect different actions, based on the ACL list for each user\n- User profile: birth date, birth location, current location, profile picture\n- Locations - save locations using google API - see Wiki for examples\n- Simple notifications system\n\n### \u003ca id=\"installation\"\u003e\u003c/a\u003eInstallation\n\nThe recommended installation is via Composer. Just add the following line to your `composer.json`:\n\n```json\n{\n    \"require\": {\n        \"crada/phalcon-user-plugin\": \"~2.0\"\n    }\n}\n```\n\n```bash\n$ php composer.phar update\n```\n\n### \u003ca id=\"plug-it\"\u003e\u003c/a\u003ePlug it\n\nAdd the following lines where to your events manager:\n\n```php\n\n$security = new \\Phalcon\\UserPlugin\\Plugin\\Security($di);\n$eventsManager-\u003eattach('dispatch', $security);\n\n```\n\nFull example code:\n\n```php\nuse Phalcon\\UserPlugin\\Plugin\\Security as SecurityPlugin;\nuse Phalcon\\Mvc\\Dispatcher;\n\n$di-\u003esetShared(\n    'dispatcher',\n    function() use ($di) {\n        $eventsManager = $di-\u003egetShared('eventsManager');\n\n        $security = new SecurityPlugin($di);\n        $eventsManager-\u003eattach('dispatch', $security);\n\n        $dispatcher = new Dispatcher();\n        $dispatcher-\u003esetEventsManager($eventsManager);\n\n        return $dispatcher;\n    }\n);\n```\n\nRegister Auth, Mail and Acl services\n\n```php\nuse Phalcon\\UserPlugin\\Auth\\Auth;\nuse Phalcon\\UserPlugin\\Acl\\Acl;\nuse Phalcon\\UserPlugin\\Mail\\Mail;\n\n$di-\u003esetShared(\n    'auth',\n    function() {\n        return new Auth();\n    }\n);\n\n$di-\u003esetShared(\n    'acl',\n    function() {\n        return new Acl();\n    }\n);\n\n$di-\u003esetShared(\n    'mail',\n    function() {\n        return new Mail();\n    }\n);\n```\n\n### \u003ca id=\"configuration\"\u003e\u003c/a\u003eConfiguration\n\nYou must add configuration keys to your config.php file. If you are using a multimodule application, i recommend\nyou to set up the configuration separately for each module.\n\n#### Configuration examples\n\nIn the example bellow, you will treat your website as public, EXCEPT the actions ACCOUNT and PROFILE from the USER\ncontroller:\n\n```php\n'pup' =\u003e [\n    'redirect' =\u003e [\n        'success' =\u003e 'user/profile',\n        'failure' =\u003e 'user/login'    \n    ],\n    'resources' =\u003e [\n        'type' =\u003e 'public',\n        'resources' =\u003e [\n            '*' =\u003e [\n                // All except\n                'user' =\u003e ['account', 'profile']\n            ]\n        ]\n    ]\n];\n```\n\nIn the example bellow, the ONLY PUBLIC resources are the actions LOGIN and REGISTER from the USER controller:\n\n```php\n'pup' =\u003e [\n    'redirect' =\u003e [\n        'success' =\u003e 'user/profile',\n        'failure' =\u003e 'user/login'    \n    ],\n    'resources' =\u003e [\n        'type' =\u003e 'public',\n        'resources' =\u003e [\n            'user' =\u003e [\n                'user' =\u003e ['login', 'register']\n            ]\n        ]\n    ]\n];\n```\n\nIn the example bellow, you will treat your website as private, EXCEPT the actions LOGIN and REGISTER from the USER\ncontroller:\n\n```php\n'pup' =\u003e [\n    'redirect' =\u003e [\n        'success' =\u003e 'user/profile',\n        'failure' =\u003e 'user/login'    \n    ],\n    'resources' =\u003e [\n        'type' =\u003e 'private',\n        'resources' =\u003e [\n            '*' =\u003e [\n                // All except\n                'user' =\u003e ['login', 'register']\n            ]\n        ]\n    ]\n];\n```\n\nIn the example bellow, the ONLY PRIVATE resources are the actions ACCOUNT and PROFILE from the USER controller:\n\n```php\n'pup' =\u003e [\n    'redirect' =\u003e [\n        'success' =\u003e 'user/profile',\n        'failure' =\u003e 'user/login'    \n    ],\n    'resources' =\u003e [\n        'type' =\u003e 'private',\n        'resources' =\u003e [\n            'user' =\u003e [\n                'user' =\u003e ['account', 'profile']\n            ]\n        ]\n    ]\n];\n```\n\nConfiguration example with connectors:\n\n```php\n// phalcon-user-plugin\n'pup' =\u003e [\n    'redirect' =\u003e [\n        'success' =\u003e 'user/profile',\n        'failure' =\u003e 'user/login'    \n    ],\n    'resources' =\u003e [\n        'type' =\u003e 'public',\n        'resources' =\u003e [\n            '*' =\u003e [\n                // All except\n                'user' =\u003e ['account', 'profile']\n            ]\n        ]\n    ],\n    'connectors' =\u003e [\n        'facebook' =\u003e [\n            'appId' =\u003e 'YOUR_FACEBOOK_APP_ID',\n            'secret' =\u003e 'YOUR_FACEBOOK_APP_SECRET'\n        ],\n        'linkedIn' =\u003e [\n            'api_key' =\u003e 'YOUR_LINKED_IN_APP_ID',\n            'api_secret' =\u003e 'YOUR_LINKED_IN_APP_SECRET',\n            'callback_url' =\u003e 'CALLBACK_URL'\n        ],\n        'twitter' =\u003e [\n            'consumer_key' =\u003e 'TWITTER_CONSUMER_KEY',\n            'consumer_secret' =\u003e 'TWITTER_CONSUMER_SECRET',\n            // Leave empty if you don't want to set it\n            'user_agent' =\u003e 'YOUR_APPLICATION_NAME'\n        ],\n        'google' =\u003e [\n            'application_name' =\u003e 'YOUR_APPLICATION_NAME',\n            'client_id' =\u003e 'YOUR_CLIENT_ID',\n            'client_secret' =\u003e 'YOUR_CLIENT_SECRET',\n            'developer_key' =\u003e 'YOUR_DEVELOPER_KEY',\n            'redirect_uri' =\u003e 'YOUR_REDIRECT_URI'\n        ]\n    ]\n];\n```\n\n### \u003ca id=\"example-controller\"\u003e\u003c/a\u003eExample controller\n\n* For a complete controller example read the Wiki page: https://github.com/calinrada/PhalconUserPlugin/wiki/Controller\n\n```php\nclass UserController extends Controller\n{\n    /**\n     * Login user\n     * @return \\Phalcon\\Http\\ResponseInterface\n     */\n    public function loginAction()\n    {\n        if (true === $this-\u003eauth-\u003eisUserSignedIn()) {\n            $this-\u003eresponse-\u003eredirect(['action' =\u003e 'profile']);\n        }\n\n        $form = new LoginForm();\n\n        try {\n            $this-\u003eauth-\u003elogin($form);\n        } catch (AuthException $e) {\n            $this-\u003eflash-\u003eerror($e-\u003egetMessage());\n        }\n\n        $this-\u003eview-\u003eform = $form;\n    }\n\n    /**\n     * Login with Facebook account\n     */\n    public function loginWithFacebookAction()\n    {\n        try {\n            $this-\u003eview-\u003edisable();\n            return $this-\u003eauth-\u003eloginWithFacebook();\n        } catch(AuthException $e) {\n            $this-\u003eflash-\u003eerror('There was an error connectiong to Facebook.');\n        }\n    }\n\n    /**\n     * Login with LinkedIn account\n     */\n    public function loginWithLinkedInAction()\n    {\n        try {\n            $this-\u003eview-\u003edisable();\n            $this-\u003eauth-\u003eloginWithLinkedIn();\n        } catch(AuthException $e) {\n            $this-\u003eflash-\u003eerror('There was an error connectiong to LinkedIn.');\n        }\n    }\n\n    /**\n     * Login with Twitter account\n     */\n    public function loginWithTwitterAction()\n    {\n        try {\n            $this-\u003eview-\u003edisable();\n            $this-\u003eauth-\u003eloginWithTwitter();\n        } catch(AuthException $e) {\n            $this-\u003eflash-\u003eerror('There was an error connectiong to Twitter.');\n        }\n    }\n\n    /**\n     * Login with Google account\n     */\n    public function loginWithGoogleAction()\n    {\n        try {\n            $this-\u003eview-\u003edisable();\n            $this-\u003eauth-\u003eloginWithGoogle();\n        } catch(AuthException $e) {\n            $this-\u003eflash-\u003eerror('There was an error connectiong to Google.');\n        }\n    }\n\n    /**\n     * Logout user and clear the data from session\n     *\n     * @return \\Phalcon\\Http\\ResponseInterface\n     */\n    public function signoutAction()\n    {\n        $this-\u003eauth-\u003eremove();\n        return $this-\u003eresponse-\u003eredirect('/', true);\n    }\n}\n```\n\n### \u003ca id=\"known-issues\"\u003e\u003c/a\u003eKnown issues\n- Twitter does not provide us the email. We are generating a random email for the user. It is your choice how you handle this\n\n### \u003ca id=\"examples\"\u003e\u003c/a\u003eExamples\n\n* [Notifications](https://github.com/calinrada/PhalconUserPlugin/wiki/Notifications)\n\n### \u003ca id=\"todo\"\u003e\u003c/a\u003eTODO\n- Implement CRUD templates for ACl, UserManagement, etc\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcalinrada%2FPhalconUserPlugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcalinrada%2FPhalconUserPlugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcalinrada%2FPhalconUserPlugin/lists"}