sascheh / steam-auth
允许用户使用Steam账户登录。
此包的官方仓库似乎已消失,因此该包已被冻结。
1.0.0
2020-12-29 09:58 UTC
Requires
- php: >=5.2
This package is auto-updated.
Last update: 2024-02-29 03:58:24 UTC
README
此库允许用户使用Steam账户登录您的网站。仅靠它本身并不会做很多事情,如果您想在用户成功登录后执行某些操作,则需要添加您自己的匿名函数。
为什么?
此库的目标是仅添加允许拥有Steam账户的用户登录您网站的功能,允许您自己的代码。
示例用法
$openid = new SteamAuth();
$openid->on_success = function ($steamid) {
$_SESSION["steamid"] = $steamid;
};
$openid->initiate();
此处构建类。
$openid = new SteamAuth();
我们向on_success
添加一个匿名函数,该函数在用户登录时触发。
在我们的示例函数中,我们将$steamid
保存到当前会话中。
$openid->on_success = function ($steamid) {
$_SESSION["steamid"] = $steamid;
};
在这里,我们将用户引导通过流程。
$openid->initiate();
事件
on_success(string $steamid)
当用户登录时调用on_success
,并将包含用户的steamID64。
默认情况下,它将不会做任何事情,建议您将$steamid
变量保存到当前会话中,并将用户发送到仪表板。
$openid->on_success = function ($steamid) {
$_SESSION["steamid"] = $steamid;
return header("Location: /dashboard");
};
on_cancel()
当OpenID返回的模式为cancel
时调用on_cancel
,这通常不会发生。
默认情况下,它将返回根页面。
$openid->on_cancel = function () {
return header("Location: /");
};
on_exception(Exception $exception)
当在过程中抛出异常时调用on_exception
。
默认情况下,它将打印异常消息并退出。
$this->on_exception = function (\Exception $e) {
print $e->getMessage();
exit;
};
拉取请求
只要它不违背此库的目的,我们始终欢迎PR。
感谢
- iignatov 和 LightOpenID 的贡献者,它使用该库(进行了一些编辑)来处理OpenID协议。