Example #1
0
/**
 * 
 * @param type $data
 * @return type
 * Validate username and password before assigning token.
 */
function loginuser($data)
{
    $mail = $data['email'];
    $password = $data['password'];
    $dd = new FinditDynamoDbUser();
    if (filter_var($mail, FILTER_VALIDATE_EMAIL) === false) {
        $output = FALSE;
        exit('Invalid email id.');
    }
    $user = $dd->validateuseraccount($mail, $password);
    return $user;
}
Example #2
0
                </tr>
                <tr>
                    <td colspan="2">
                        <input name ="submit" type="submit" value="submit">
                    </td>
                </tr>
                <input type="hidden" name="op" value="' . $_GET['op'] . '">
                <input type="hidden" name="redirect_uri" value="' . $_GET['redirecturl'] . '">    
            </table>
        </form>
    </body>
</html>';
}
if (!empty($_POST)) {
    $data = $_POST;
    $user = new FinditDynamoDbUser();
    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 {