Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I added the function getOTPUrl to get the otp:// url from the secret #84

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions PHPGangsta/GoogleAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,22 @@ public function getQRCodeGoogleUrl($name, $secret, $title = null, $params = arra
return "https://api.qrserver.com/v1/create-qr-code/?data=$urlencoded&size=${width}x${height}&ecc=$level";
}

/**
* Get OTP:// - Url
* @param string $name
* @param string $secret
* @param string $title
*
* @return string
*/
public function getOTPUrl($name,$secret,$title = null){
$url = 'otpauth://totp/'.$name.'?secret='.$secret;
if (isset($title)) {
$url .= "&issuer=$title";
}
return ($url);
}

/**
* Check if the code is correct. This will accept codes starting from $discrepancy*30sec ago to $discrepancy*30sec from now.
*
Expand Down