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

feat: phone authentication #3357

Merged
merged 23 commits into from Jun 20, 2022
Merged

feat: phone authentication #3357

merged 23 commits into from Jun 20, 2022

Conversation

TorstenDittmann
Copy link
Contributor

@TorstenDittmann TorstenDittmann commented Jun 8, 2022

Todo

  • fix naming conventions for the classes (they are all over the place right now)
  • considering the approach for env variables we have for storage
  • add missing tests for the users service
  • add all the documentation
  • update UI

What does this PR do?

Adds the option to use your phone as a method of authentication.

The initial implementation will allow using the following 3 providers:

A Messaging Worker has been added to the Stack.

Following attributes have been added to the user:

  • phone
  • phoneVerification

Following env variables have been added:

  • _APP_PHONE_PROVIDER
  • _APP_PHONE_USER
  • _APP_PHONE_SECRET
  • _APP_PHONE_FROM

Following endpoints have been added:

Create Phone Session
post('/v1/account/sessions/phone')

  • userId
  • number

Will initialize the phone login and sends 6 random digits to the phone.

Create Phone session (confirmation)
put('/v1/account/sessions/phone')

  • userId
  • secret

Will confirm the the session and create a user account if not found. The 6 digits will be passed as the secret.

Update Account Phone
patch('/v1/account/phone')

  • number
  • password

Updates the users phone number.

Create Phone Verification
post('/v1/account/verification/phone')

  • no params

Creates a verification token and sends 6 digits to the user's phone.

Create Phone Verification (confirmation)
put('/v1/account/verification/phone')

  • userId
  • secret

Confirms the phone number by passing the 6 digits as the secret.

Update Phone
patch('/v1/users/:userId/email')

  • userId
  • number

Updates the user's phone number.

Update Phone Verification
patch('/v1/users/:userId/verification')

  • userId
  • phoneVerification

Updates the phoneVerification attribute on the user.

Test Plan

  • added tests for all the new endpoints using a mock adapter for the
  • manually tested all 3 adapters

Related PRs and Issues

Have you read the Contributing Guidelines on issues?

.env Outdated Show resolved Hide resolved
app/controllers/api/users.php Show resolved Hide resolved
app/controllers/api/users.php Outdated Show resolved Hide resolved
app/init.php Outdated Show resolved Hide resolved
app/workers/messaging.php Outdated Show resolved Hide resolved
src/Appwrite/Auth/Phone.php Show resolved Hide resolved
src/Appwrite/Utopia/Response/Model/User.php Outdated Show resolved Hide resolved
src/Appwrite/Utopia/Response/Model/User.php Outdated Show resolved Hide resolved
app/controllers/api/account.php Show resolved Hide resolved
@TorstenDittmann TorstenDittmann marked this pull request as ready for review June 20, 2022 15:57
@TorstenDittmann TorstenDittmann merged commit e6edcb5 into 0.15.x Jun 20, 2022
@TorstenDittmann TorstenDittmann deleted the feat-phone-authentication branch June 20, 2022 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants