Skip to content

Commit

Permalink
Merge pull request #66 from BRACKETS-by-TRIAD/feat/update-docs-before…
Browse files Browse the repository at this point in the history
…-release-1.2.0

Feat/update docs before release 1.2.0
  • Loading branch information
strstensky authored Dec 6, 2023
2 parents 829072f + e5ae6dc commit 8db6b64
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 1 deletion.
1 change: 1 addition & 0 deletions pages/basic-features.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
} from "@heroicons/react/24/outline";

<Cards>
<Card icon={<UsersIcon />} title="Social Login" href="/basic-features/social-login" />
<Card icon={<UsersIcon />} title="Users" href="/basic-features/users" />
<Card
icon={<LanguageIcon />}
Expand Down
1 change: 1 addition & 0 deletions pages/basic-features/_meta.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"social-login": "Social Login",
"users": "Users",
"translations": "Translations",
"roles-permissions": "Roles & Permissions",
Expand Down
3 changes: 2 additions & 1 deletion pages/basic-features/roles-permissions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ Thanks to Craftable PRO you have been given all you need for setting roles and p

## Roles

By default, Craftable PRO comes with tho main roles: Administrator and Guest. You are able to define as many roles as you need, all you need to do is create the migration that will add a new role.
By default, Craftable PRO comes with two main roles: Administrator and Guest. You are able to create as many roles as you need after clicking on "Add role". You are also able to edit and delete the role after clicking on the icons in the listing.
To delete a role, first make sure that no user has it assigned.

<br />
<Image alt="Roles" src="/images/roles.png" />
Expand Down
95 changes: 95 additions & 0 deletions pages/basic-features/social-login.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import { Callout, Tabs, Tab } from "nextra-theme-docs";

# Social Login

This feature empowers you to seamlessly integrate social login functionality into your application, enhancing user experience and engagement. Craftable PRO supports various popular social platforms, including Facebook, GitHub, Twitter, Apple, Google, and Microsoft, allowing your users to sign in using their preferred social accounts effortlessly.
The functionality is powered by the [Laravel Socialite](https://laravel.com/docs/socialite) package and its extensive range of providers.

## Getting Started

To enable social login in your application, follow these simple steps:

<div className="steps-container">
### Select which services you want to use and enable them in `config/craftable-pro.php`:
```php filename="config/craftable-pro.php"
'social_login' => [
'allowed_services' => [
'microsoft' => false,
'github' => true,
'google' => true,
'twitter' => false,
'facebook' => false,
'apple' => false,
],
'self_registration' => [
// define if users can self register into craftable pro interface
'enabled' => true,
// and if enabled, then which role(s) they should have assigned by default. Use role names here.
// It can be a string for one role or an array for multiple roles.
'default_role' => 'Administrator',
'allowed_domains' => ['craftable.pro'], // use * for allowing any domain
]
]
```
### Social login self-registration
When social login self-registration is enabled, users can register conveniently through various social logins. However, if disabled, users will only gain access to social login after a CraftableProUser instance has been generated for them in the Access tab.

To permit registration for emails from any domain, adjust the configuration to `'allowed_domains' => ['*']`.
To allow registration only for emails from a specific domain (e.g., @mydomain.com), modify the configuration to `'allowed_domains' => ['mydomain.com'].`"
### Register event listeners for your enabled providers in `app/Providers/EventServiceProvider.php`:
```text filename="app/Providers/EventServiceProvider.php"
protected $listen = [
\SocialiteProviders\Manager\SocialiteWasCalled::class => [
\SocialiteProviders\Apple\MicrosoftExtendSocialite::class,
\SocialiteProviders\Apple\GitHubExtendSocialite::class,
\SocialiteProviders\Apple\TwitterExtendSocialite::class,
\SocialiteProviders\Apple\FacebookExtendSocialite::class,
\SocialiteProviders\Apple\GoogleExtendSocialite::class,
\SocialiteProviders\Apple\AppleExtendSocialite::class,
]
];
```
### Get client credentials from the providers and put them in your `.env`:
```php filename=".env"
MICROSOFT_CLIENT_ID=
MICROSOFT_CLIENT_SECRET=
MICROSOFT_REDIRECT_URI="/admin/login/microsoft/callback"

GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
GITHUB_REDIRECT_URI="/admin/login/github/callback"

GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GOOGLE_REDIRECT_URL="/admin/login/google/callback"

TWITTER_CLIENT_ID=
TWITTER_CLIENT_SECRET=
TWITTER_REDIRECT_URI="/admin/login/twitter/callback"

FACEBOOK_CLIENT_ID=
FACEBOOK_CLIENT_SECRET=
FACEBOOK_REDIRECT_URI="/admin/login/facebook/callback"

APPLE_CLIENT_ID=
APPLE_CLIENT_SECRET=
APPLE_REDIRECT_URI="/admin/login/apple/callback"
```
</div>

## Other providers

To use another existing provider, check out the [Laravel Socialite](https://laravel.com/docs/socialite) or [Laravel Socialite Providers](https://socialiteproviders.com/) documentation.

To create a new custom provider, follow the steps outlined [here](https://socialiteproviders.com/contribute/#creating-a-provider).
To enable your new provider in Craftable Pro, don't forget to add it to the config:
```php filename="config/craftable-pro.php"
'social_login' => [
'allowed_services' => [
'myNewProvider' => true
...
],
...
]
```
as well as to implement a login button for it on the login page.
Binary file modified public/images/roles.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8db6b64

Please sign in to comment.