Ejemplo n.º 1
0
/**
 * 
 * @param type $mail
 * @return boolean
 * Validate email before creating user account.
 */
function validateemail($mail)
{
    $output = TRUE;
    $dd = new FinditDynamoDbUser();
    $count = $dd->getUserCountByMail($mail);
    if ($count) {
        $output = FALSE;
        exit('Email already exist.');
    }
    if (filter_var($mail, FILTER_VALIDATE_EMAIL) === false) {
        $output = FALSE;
        exit('Invalid email id.');
    }
    return $output;
}
Ejemplo n.º 2
0
    if ($data['op'] == 'login') {
        $result = $user->validateuseraccount($_POST['email'], $_POST['password']);
        if ($result['status']) {
            $data = array();
            $data['email'] = $result['email']['S'];
            $data['name'] = $result['name']['S'];
            $data['id'] = $result['id']['S'];
            $cookie = base64_encode(serialize($data));
            setcookie('Findit_user', $cookie, 0, '/', '.findit.com');
            $location = $_POST['redirect_uri'];
            header("Location: {$location}");
        } else {
            echo 'Somrthing went wrong.Please try again.';
        }
    } else {
        $count = $user->getUserCountByMail($_POST['email']);
        if ($count) {
            echo 'Used with this email id already exist';
        } else {
            $result = $user->createUserProfile($data);
            $data = array();
            $data['email'] = $result['email']['S'];
            $data['name'] = $result['name']['S'];
            $data['id'] = $result['id']['S'];
            $cookie = base64_encode(serialize($data));
            setcookie('Findit_user', $cookie, 0, '/', '.findit.com');
            $location = $_POST['redirect_uri'];
            header("Location: {$location}");
        }
    }
}