Clean up member_auth_mail table schema, adding auth_type column

This commit is contained in:
Kijin Sung 2023-11-28 22:08:22 +09:00
parent c2311f88be
commit b934b8638f
5 changed files with 41 additions and 7 deletions

View file

@ -170,6 +170,12 @@ class Member extends ModuleObject
if(!$oDB->isColumnExists('member_devices', 'device_token_type')) return true;
if(!$oDB->isColumnExists('member_devices', 'last_active_date')) return true;
// Check member_auth_mail table
if(!$oDB->isColumnExists('member_auth_mail', 'auth_type')) return true;
if(!$oDB->isIndexExists('member_auth_mail', 'unique_auth_key')) return true;
if(!$oDB->isIndexExists('member_auth_mail', 'idx_member_srl')) return true;
if($oDB->isIndexExists('member_auth_mail', 'unique_key')) return true;
// Update status column
$output = executeQuery('member.getDeniedAndStatus');
if ($output->data->count)
@ -383,6 +389,25 @@ class Member extends ModuleObject
$oDB->query("UPDATE member_devices SET last_active_date = regdate WHERE last_active_date = ''");
}
// Check member_auth_mail table
if(!$oDB->isColumnExists('member_auth_mail', 'auth_type'))
{
$oDB->addColumn('member_auth_mail', 'auth_type', 'varchar', '20', 'password_v1', true, 'new_password');
$oDB->query("UPDATE member_auth_mail SET auth_type = 'signup' WHERE is_register = 'Y'");
}
if(!$oDB->isIndexExists('member_auth_mail', 'unique_auth_key'))
{
$oDB->addIndex('member_auth_mail', 'unique_auth_key', ['auth_key'], true);
}
if(!$oDB->isIndexExists('member_auth_mail', 'idx_member_srl'))
{
$oDB->addIndex('member_auth_mail', 'idx_member_srl', ['member_srl']);
}
if($oDB->isIndexExists('member_auth_mail', 'unique_key'))
{
$oDB->dropIndex('member_auth_mail', 'unique_key');
}
// Update status column
$output = executeQuery('member.getDeniedAndStatus');
if ($output->data->count)

View file

@ -1670,6 +1670,7 @@ class MemberController extends Member
$args->member_srl = $member_info->member_srl;
$args->new_password = Rhymix\Framework\Password::getRandomPassword(8);
$args->auth_key = Rhymix\Framework\Security::getRandom(40, 'hex');
$args->auth_type = 'password_v1';
$args->is_register = 'N';
$output = executeQuery('member.insertAuthMail', $args);
@ -2858,6 +2859,7 @@ class MemberController extends Member
$auth_args->member_srl = $args->member_srl;
$auth_args->new_password = $args->password;
$auth_args->auth_key = Rhymix\Framework\Security::getRandom(40, 'hex');
$args->auth_type = 'signup';
$auth_args->is_register = 'Y';
$output = executeQuery('member.insertAuthMail', $auth_args);
@ -3435,6 +3437,8 @@ class MemberController extends Member
$auth_args->member_srl = $member_info->member_srl;
$auth_args->auth_key = Rhymix\Framework\Security::getRandom(40, 'hex');
$auth_args->new_password = 'XE_change_emaill_address';
$auth_args->auth_type = 'change_email';
$auth_args->is_register = 'N';
$output = executeQuery('member.insertAuthMail', $auth_args);
if(!$output->toBool())
@ -3499,7 +3503,7 @@ class MemberController extends Member
$output = executeQuery('member.updateMemberEmailAddress', $args);
if(!$output->toBool()) return $output;
// Remove all values having the member_srl and new_password equal to 'XE_change_emaill_address' from authentication table
// Remove all values having the member_srl and auth_type = change_email
executeQuery('member.deleteAuthChangeEmailAddress',$args);
self::clearMemberCache($args->member_srl);

View file

@ -4,6 +4,9 @@
</tables>
<conditions>
<condition operation="equal" column="member_srl" var="member_srl" notnull="notnull" />
<condition operation="equal" column="new_password" default="XE_change_emaill_address" notnull="notnull" pipe="and" />
<group pipe="and">
<condition operation="equal" column="new_password" default="XE_change_emaill_address" />
<condition operation="equal" column="auth_type" default="change_email" pipe="or" />
</group>
</conditions>
</query>

View file

@ -3,10 +3,11 @@
<table name="member_auth_mail" />
</tables>
<columns>
<column name="auth_key" var="auth_key" notnull="notnull" minlength="1" maxlength="60" />
<column name="member_srl" var="member_srl" filter="number" notnull="notnull" />
<column name="user_id" var="user_id" notnull="notnull" />
<column name="auth_key" var="auth_key" notnull="notnull" minlength="1" maxlength="60" />
<column name="new_password" var="new_password" notnull="notnull" />
<column name="auth_type" var="auth_type" default="password_v1" />
<column name="is_register" var="is_register" default="N" />
<column name="regdate" default="curdate()" />
</columns>

View file

@ -1,8 +1,9 @@
<table name="member_auth_mail">
<column name="auth_key" type="varchar" size="60" notnull="notnull" unique="unique_key" />
<column name="member_srl" type="number" size="11" notnull="notnull" unique="unique_key" />
<column name="auth_key" type="varchar" size="60" notnull="notnull" unique="unique_auth_key" />
<column name="member_srl" type="number" size="11" notnull="notnull" index="idx_member_srl" />
<column name="user_id" type="varchar" size="80" notnull="notnull" />
<column name="new_password" type="varchar" size="250" notnull="notnull" />
<column name="is_register" type="char" size="1" default="N" />
<column name="regdate" type="date" index="idx_regdate" />
<column name="auth_type" type="varchar" size="20" notnull="notnull" default="password_v1" />
<column name="is_register" type="char" size="1" notnull="notnull" default="N" />
<column name="regdate" type="date" notnull="notnull" index="idx_regdate" />
</table>