burdapraha / sso-api
此软件包最新版本(v3.1.6)没有可用的许可信息。
双确认注册
v3.1.6
2021-09-14 10:21 UTC
Requires
- ext-curl: *
- ext-json: *
- nette/mail: 2.4.6 - 3.1.6
README
在任意PHP框架或基本网页中极易于使用。轻松切换PROD和DEV版本
内容
版本
状态 | 版本 | 分支 | PHP |
---|---|---|---|
稳定 | ^2.0.4 | master | >= 5.6 |
dev | ^3.0.0 | master | >= 5.6 |
安装
安装软件包
composer require burdapraha/sso-api
设置
基本网页
SSOApi 配置 - 获取它,您需要联系供应商
$ssoConfig = [
"apiHash" => "",
"environment" => \BurdaPraha\SSOApi\SSOInterface::PROD,
];
SMTP 配置
$smtpConfig = [
"host" => "",
"port" => "",
"username" => "",
"password" => "",
"secure" => "",
"emailFrom" => "",
"emailReplayTo" => "",
];
模板路径 - 模板HTML的路径或URL
$templatePaths = [
"confirmRegistration" => [
"subject" => "subject"
"paths" => [
"basic" => __DIR__ . "/confirmRegistrationBasic.html",
"google" => __DIR__ . "/confirmRegistrationGoogle.html",
],
],
"confirmation" => [
"subject" => "subject"
"paths" => [
"basic" => __DIR__ . "/confirmationBasic.html",
"google" => __DIR__ . "/confirmationGoogle.html",
],
],
"forgottenPassword" => [
"subject" => "subject"
"paths" => [
"basic" => __DIR__ . "/forgottenPasswordBasic.html",
"google" => __DIR__ . "/forgottenPasswordGoogle.html",
],
],
];
创建SSOApi实例
$sso = new BurdaPraha\SSOApi\SSOApi($ssoConfig, $smtpConfig, $templatePaths);
$sso->addAuthorization($key, $value); #Bearer token
Nette 框架
config.neon
parameters:
ssoApi:
ssoConfig:
hash: ""
environment: "prod"
smtpConfig:
host: ""
port: ""
username: ""
password: ""
secure: ""
emailFrom: ""
emailReplayTo: ""
templatePaths:
confirmRegistration:
path:
pathPlain:
subject:
confirmRegistrationGoogle:
path:
pathPlain:
subject:
services:
- BurdaPraha\SSOApi\SSOApi(%ssoApi.ssoConfig%, %ssoApi.smtpConfig%, %ssoApi.templatePaths%)
注册
- 首次使用方法
createContact
,此方法检查联系人是否存在,然后插入或更新联系人并返回 响应 - 验证邮件中必须包含对该方法的链接
setVerifyUserByHash
用法
getContactByEmail(string $email): array
通过电子邮件获取联系人,返回数组
$sso->getUserData("example@example.com");
getContactByHash(string $hash): array
通过哈希获取联系人,返回数组
$sso->getContactByHash("hash");
isEmailVerified(string $email): bool
检查电子邮件是否存在并返回 布尔值。
$sso->isEmailVerified("example@example.com");
existEmail(string $email): bool
检查电子邮件是否已验证并返回 布尔值。
$sso->existEmail("example@example.com");
setVerifiedByEmail(string $email, bool $sendEmail = true): Response
将电子邮件地址的联系人标记为已验证,并可以选择禁用发送电子邮件,返回 响应
$sso->setVerifiedByEmail("example@example.com");
setVerifiedByHash(string $hash, bool $sendEmail = true): Response
将哈希地址的联系人标记为已验证,并可以选择禁用发送电子邮件,返回 响应
$sso->setVerifiedByHash("hash");
createContact(array $data): Response
创建或更新联系人,可能的列在类 BurdaPraha\SSOApi\Enums\ContactColumnEnum 中,返回 响应
$data = [ BurdaPraha\SSOApi\Enums\ContactColumnEnum::EMAIL => "example@example.com", ]; $sso->createContact($data);
sendResetPasswordEmail(string $email, ?string $emailFrom = null): Response
发送重置密码的电子邮件,返回 响应
$sso->sendResetPasswordEmail("example@example.com", "myemail@example.com");
resetPassword(string $email, string $passwordVerificationHash, string $password): Response
重置密码,返回 响应
$sso->resetPassword("example@example.com", "passwordVerificationHash", "password");
getToken(string $email, string $password): string
获取用户令牌,返回字符串令牌
$sso->getToken("example@example.com", "password");
getGroupsAll(): array
获取所有组。
$sso->getGroupsAll();
getHobbiesAll(): array
获取所有爱好。
$sso->getHobbiesAll();
getAgreementTypes(): array
获取所有协议类型。
$sso->getAgreementTypes();
其他
谢谢大家。