3
デバイスのudidに基づいて制限ログインを作成したいと考えています。たとえば、ユーザーは2つの異なるデバイスで同時にログインすることができます。これは私がやったが、ログインがログインの制限番号
// Get the email and password
$email = CParam::paramPost('email');
$firstpassword = CParam::paramPost('password');
$password = md5(CParam::paramPost('password'));
$udid = CParam::paramPost('udid');
$app_id = CParam::paramPost('app_id');
$app_version = CParam::paramPost('app_version');
// Make sure we have a UDID
if (empty($udid)) {
sendJsonError('UDID parameter is missing');
return;
}
// Check if the user is entitled
$sql = 'SELECT * FROM accounts WHERE email = :email AND password = :password';
$params = array('email' => $email, 'password' => $password);
$account = $db->fetchOne($sql, $params);
if (!$account) {
sendJsonError('We could not find your subscription.');
return;
}
// The account was found, generate an successs token if not existing yet
if (empty($account['success_token'])) {
$success_token = CGuid::create();
$db->update(
'accounts',
array('success_token' => $success_token),
'id = :id',
array('id' => $account['id'])
);
} else {
$success_token = $account['success_token'];
}
// Register the device
$db->insertOrUpdate(
'devices',
array(
'account_id' => $account['id'],
'udid' => $udid,
'app_id' => $app_id,
'app_version' => $app_version,
)
);
おかげ
Sidenote:私はあなたが 'password_hash()'のようなMD5より安全なパスワードハッシュを使いたいと思っています。 –
こんにちは、あなたのコードには、ユーザーが生成したsuccess_tokensの数を確認する条件はありません。 – Jimmmy
こんにちは@ジムミー、いいえ、私はまだ条件を作成していません。まだウェブ上で条件チュートリアルを書く方法を見つけようとしていますが、誰もまだ働いていません、アドバイスをお願いしますか? –