mirror of
https://github.com/YunoHost-Apps/hubzilla_ynh.git
synced 2024-09-03 19:26:21 +02:00
25 lines
794 B
PHP
25 lines
794 B
PHP
|
<?php
|
||
|
# Logging in with Google accounts requires setting special identity, so this example shows how to do it.
|
||
|
require 'openid.php';
|
||
|
try {
|
||
|
# Change 'localhost' to your domain name.
|
||
|
$openid = new LightOpenID('localhost');
|
||
|
if(!$openid->mode) {
|
||
|
if(isset($_GET['login'])) {
|
||
|
$openid->identity = 'https://www.google.com/accounts/o8/id';
|
||
|
header('Location: ' . $openid->authUrl());
|
||
|
}
|
||
|
?>
|
||
|
<form action="?login" method="post">
|
||
|
<button>Login with Google</button>
|
||
|
</form>
|
||
|
<?php
|
||
|
} elseif($openid->mode == 'cancel') {
|
||
|
echo 'User has canceled authentication!';
|
||
|
} else {
|
||
|
echo 'User ' . ($openid->validate() ? $openid->identity . ' has ' : 'has not ') . 'logged in.';
|
||
|
}
|
||
|
} catch(ErrorException $e) {
|
||
|
echo $e->getMessage();
|
||
|
}
|