私は次の表を持っています
ログイン
IdUser (整数)
ユーザー名(varchar)
パスワード(varchar)
メール(varchar)
アクティブ(整数)
Active は、ユーザーの電子メールが検証されているかどうかに応じて、0 または 1 になります。アカウントが確認されると、テーブルのアクティブな行は 1 で更新されます。アカウントが確認されない場合、テーブルのアクティブな行は 0 のままです。
ユーザーは、アカウントが確認された場合にのみログインできるようにする必要があります。
これまでのところ、私のログインは次のように機能します。
//login API
function login($user, $pass) {
// try to match a row in the "login" table for the given username and password
$result = query("SELECT IdUser, username FROM login WHERE username='%s' AND pass='%s' limit 1", $user, $pass);
if (count($result['result'])>0) {
// a row was found in the database for username/pass combination
// save a simple flag in the user session, so the server remembers that the user is authorized
$_SESSION['IdUser'] = $result['result'][0]['IdUser'];
// print out the JSON of the user data to the iPhone app; it looks like this:
// {IdUser:1, username: "Name"}
print json_encode($result);
} else {
// no matching username/password was found in the login table
errorJson('Authorization failed');
}
}
認証済みのユーザーのみにログインを許可するにはどうすればよいですか?