diff --git a/docs/install.md b/docs/install.md index 791d23a..79157e4 100644 --- a/docs/install.md +++ b/docs/install.md @@ -52,6 +52,7 @@ Therefore, you can add `first_name`, `last_name`, and `avatar` columns to table ```console php spark migrate -n Datamweb\ShieldOAuth ``` +The default size of the `username` field created by Shield is **30** characters. Since Oauth uses the `username` field for the user's email address, this often is not large enough. Consider increasing the size of this field to `VARCHAR(256)`. _The migrations make this change for you_. > **Note** > By default, `Shield OAuth` uses columns named `first_name`, `last_name`, and `avatar`. diff --git a/src/Database/Migrations/2022-10-20-182737_ShieldOAuth.php b/src/Database/Migrations/2022-10-20-182737_ShieldOAuth.php index 2c5e621..c6ce9ef 100644 --- a/src/Database/Migrations/2022-10-20-182737_ShieldOAuth.php +++ b/src/Database/Migrations/2022-10-20-182737_ShieldOAuth.php @@ -50,10 +50,19 @@ public function up(): void 'type' => 'VARCHAR', 'constraint' => '1000', 'null' => true, - ], + ] ]; $this->forge->addColumn('users', $fields); + + $fields2 = [ + 'username' => [ + 'type' => 'VARCHAR(256)', + 'null' => true + ] + ]; + + $this->forge->modifyColumn('users', $fields2); } public function down(): void diff --git a/src/Libraries/GoogleOAuth.php b/src/Libraries/GoogleOAuth.php index eb795d2..dbd7fb5 100644 --- a/src/Libraries/GoogleOAuth.php +++ b/src/Libraries/GoogleOAuth.php @@ -96,7 +96,7 @@ protected function setColumnsName(string $nameOfProcess, $userInfo): array { if ($nameOfProcess === 'syncingUserInfo') { return [ - $this->config->usersColumnsName['first_name'] => $userInfo->name, + $this->config->usersColumnsName['first_name'] => $userInfo->given_name, $this->config->usersColumnsName['last_name'] => $userInfo->family_name ?? null, $this->config->usersColumnsName['avatar'] => $userInfo->picture, ];