burdapraha/sso-api

There is no license information available for the latest version (v3.1.6) of this package.

double opt-in registration

v3.1.6 2021-09-14 10:21 UTC

README

Ultra easy-to-use in any PHP FrameWork or basic web. Easy switch PROD and DEV version

Content

Versions

StateVersionBranchPHP
stable^2.0.4master>= 5.6
dev^3.0.0master>= 5.6

Install

Install package

composer require burdapraha/sso-api

Setup

Basic web

SSOApi Config - to get it, you need to reach out to the provider

$ssoConfig = [
    "apiHash" => "",
    "environment" => \BurdaPraha\SSOApi\SSOInterface::PROD,
];

SMTP Config

$smtpConfig = [
    "host" => "",
    "port" => "",
    "username" => "",
    "password" => "",
    "secure" => "",
    "emailFrom" => "",
    "emailReplayTo" => "",
];

Template paths - path to template html or 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",
        ],
    ],
];

Create instance SSOApi

$sso = new BurdaPraha\SSOApi\SSOApi($ssoConfig, $smtpConfig, $templatePaths);
$sso->addAuthorization($key, $value); #Bearer token

Nette FrameWork

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%)

Registration

  • first use method createContact, this method checks if the contact exists and then insert or update contact return Response
  • there must be a link to this method in the verification email setVerifyUserByHash

    Usage

    getContactByEmail(string $email): array

    Get contact by email, return array

    $sso->getUserData("example@example.com");
    

    getContactByHash(string $hash): array

    Get contact by hash, return array

    $sso->getContactByHash("hash");
    

    isEmailVerified(string $email): bool

    Checks if email exists and return boolean.

    $sso->isEmailVerified("example@example.com");
    

    existEmail(string $email): bool

    Checks if email is verified and return boolean.

    $sso->existEmail("example@example.com");
    

    setVerifiedByEmail(string $email, bool $sendEmail = true): Response

    Sets contact by email as verified and can disable send email, return Response

    $sso->setVerifiedByEmail("example@example.com");
    

    setVerifiedByHash(string $hash, bool $sendEmail = true): Response

    Sets contact by hash as verified and can disable send email, return Response

    $sso->setVerifiedByHash("hash");
    

    createContact(array $data): Response

    Create or update contact, Possible columns are in class BurdaPraha\SSOApi\Enums\ContactColumnEnum, return Response

    $data = [
      BurdaPraha\SSOApi\Enums\ContactColumnEnum::EMAIL => "example@example.com",
    ];
    $sso->createContact($data);
    

    sendResetPasswordEmail(string $email, ?string $emailFrom = null): Response

    Send email for reset password, return Response

    $sso->sendResetPasswordEmail("example@example.com", "myemail@example.com");
    

    resetPassword(string $email, string $passwordVerificationHash, string $password): Response

    Reset password, return Response

    $sso->resetPassword("example@example.com", "passwordVerificationHash", "password");
    

    getToken(string $email, string $password): string

    Get user token, return string token

    $sso->getToken("example@example.com", "password");
    

    getGroupsAll(): array

    Get all groups.

    $sso->getGroupsAll();
    

    getHobbiesAll(): array

    Get all hobbies.

    $sso->getHobbiesAll();
    

    getAgreementTypes(): array

    Get all agreement types.

    $sso->getAgreementTypes();
    

    Other

    Thank you guys.