mirror of
https://github.com/flarum/core.git
synced 2025-07-30 21:20:24 +02:00
Improve external authentication API
Some providers (e.g. Twitter) don't expose user email addresses, so it turns out we can't use that as the sole form of identification/account matching. This commit introduces a new `auth_tokens` table which stores arbitrary attributes during the sign up process. For example, when Twitter is authenticated, a new auth token containing the user's Twitter ID will be created. When sign up is completed with this token, that Twitter ID will be set as an attribute on the user's account.
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
use Flarum\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class MakeEmailTokensUserIdColumnNullable extends Migration
|
||||
class CreateAuthTokensTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
@@ -21,8 +21,10 @@ class MakeEmailTokensUserIdColumnNullable extends Migration
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
$this->schema->table('email_tokens', function (Blueprint $table) {
|
||||
$table->integer('user_id')->unsigned()->nullable()->change();
|
||||
$this->schema->create('auth_tokens', function (Blueprint $table) {
|
||||
$table->string('id', 100)->primary();
|
||||
$table->string('payload', 150);
|
||||
$table->timestamp('created_at');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -33,8 +35,6 @@ class MakeEmailTokensUserIdColumnNullable extends Migration
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
$this->schema->table('email_tokens', function (Blueprint $table) {
|
||||
$table->integer('user_id')->unsigned()->change();
|
||||
});
|
||||
$this->schema->drop('auth_tokens');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user