2022-01-21 06:48:07 +00:00
|
|
|
package providers
|
|
|
|
|
2022-01-25 05:27:40 +00:00
|
|
|
import (
|
2022-07-10 16:19:33 +00:00
|
|
|
"context"
|
|
|
|
|
2022-01-25 05:27:40 +00:00
|
|
|
"github.com/authorizerdev/authorizer/server/db/models"
|
|
|
|
"github.com/authorizerdev/authorizer/server/graph/model"
|
|
|
|
)
|
2022-01-21 06:48:07 +00:00
|
|
|
|
|
|
|
type Provider interface {
|
|
|
|
// AddUser to save user information in database
|
2023-07-31 11:12:11 +00:00
|
|
|
AddUser(ctx context.Context, user *models.User) (*models.User, error)
|
2022-01-21 06:48:07 +00:00
|
|
|
// UpdateUser to update user information in database
|
2023-07-31 11:12:11 +00:00
|
|
|
UpdateUser(ctx context.Context, user *models.User) (*models.User, error)
|
2022-01-21 06:48:07 +00:00
|
|
|
// DeleteUser to delete user information from database
|
2023-07-31 11:12:11 +00:00
|
|
|
DeleteUser(ctx context.Context, user *models.User) error
|
2022-01-21 06:48:07 +00:00
|
|
|
// ListUsers to get list of users from database
|
2023-07-31 11:12:11 +00:00
|
|
|
ListUsers(ctx context.Context, pagination *model.Pagination) (*model.Users, error)
|
2022-01-21 06:48:07 +00:00
|
|
|
// GetUserByEmail to get user information from database using email address
|
2023-07-31 11:12:11 +00:00
|
|
|
GetUserByEmail(ctx context.Context, email string) (*models.User, error)
|
2022-12-21 17:44:24 +00:00
|
|
|
// GetUserByPhoneNumber to get user information from database using phone number
|
|
|
|
GetUserByPhoneNumber(ctx context.Context, phoneNumber string) (*models.User, error)
|
2022-01-21 06:48:07 +00:00
|
|
|
// GetUserByID to get user information from database using user ID
|
2023-07-31 11:12:11 +00:00
|
|
|
GetUserByID(ctx context.Context, id string) (*models.User, error)
|
2022-08-02 08:42:36 +00:00
|
|
|
// UpdateUsers to update multiple users, with parameters of user IDs slice
|
|
|
|
// If ids set to nil / empty all the users will be updated
|
|
|
|
UpdateUsers(ctx context.Context, data map[string]interface{}, ids []string) error
|
2022-01-21 06:48:07 +00:00
|
|
|
|
|
|
|
// AddVerification to save verification request in database
|
2023-07-31 11:12:11 +00:00
|
|
|
AddVerificationRequest(ctx context.Context, verificationRequest *models.VerificationRequest) (*models.VerificationRequest, error)
|
2022-01-21 06:48:07 +00:00
|
|
|
// GetVerificationRequestByToken to get verification request from database using token
|
2023-07-31 11:12:11 +00:00
|
|
|
GetVerificationRequestByToken(ctx context.Context, token string) (*models.VerificationRequest, error)
|
2022-01-21 06:48:07 +00:00
|
|
|
// GetVerificationRequestByEmail to get verification request by email from database
|
2023-07-31 11:12:11 +00:00
|
|
|
GetVerificationRequestByEmail(ctx context.Context, email string, identifier string) (*models.VerificationRequest, error)
|
2022-01-21 06:48:07 +00:00
|
|
|
// ListVerificationRequests to get list of verification requests from database
|
2023-07-31 11:12:11 +00:00
|
|
|
ListVerificationRequests(ctx context.Context, pagination *model.Pagination) (*model.VerificationRequests, error)
|
2022-01-21 06:48:07 +00:00
|
|
|
// DeleteVerificationRequest to delete verification request from database
|
2023-07-31 11:12:11 +00:00
|
|
|
DeleteVerificationRequest(ctx context.Context, verificationRequest *models.VerificationRequest) error
|
2022-01-21 06:48:07 +00:00
|
|
|
|
|
|
|
// AddSession to save session information in database
|
2023-07-31 11:12:11 +00:00
|
|
|
AddSession(ctx context.Context, session *models.Session) error
|
2023-08-01 10:39:17 +00:00
|
|
|
// DeleteSession to delete session information from database
|
|
|
|
DeleteSession(ctx context.Context, userId string) error
|
2022-01-21 06:48:07 +00:00
|
|
|
|
|
|
|
// AddEnv to save environment information in database
|
2023-07-31 11:12:11 +00:00
|
|
|
AddEnv(ctx context.Context, env *models.Env) (*models.Env, error)
|
2022-01-21 06:48:07 +00:00
|
|
|
// UpdateEnv to update environment information in database
|
2023-07-31 11:12:11 +00:00
|
|
|
UpdateEnv(ctx context.Context, env *models.Env) (*models.Env, error)
|
2022-01-21 06:48:07 +00:00
|
|
|
// GetEnv to get environment information from database
|
2023-07-31 11:12:11 +00:00
|
|
|
GetEnv(ctx context.Context) (*models.Env, error)
|
2022-07-06 05:08:21 +00:00
|
|
|
|
|
|
|
// AddWebhook to add webhook
|
2023-07-31 11:12:11 +00:00
|
|
|
AddWebhook(ctx context.Context, webhook *models.Webhook) (*model.Webhook, error)
|
2022-07-06 05:08:21 +00:00
|
|
|
// UpdateWebhook to update webhook
|
2023-07-31 11:12:11 +00:00
|
|
|
UpdateWebhook(ctx context.Context, webhook *models.Webhook) (*model.Webhook, error)
|
2022-07-06 05:08:21 +00:00
|
|
|
// ListWebhooks to list webhook
|
2023-07-31 11:12:11 +00:00
|
|
|
ListWebhook(ctx context.Context, pagination *model.Pagination) (*model.Webhooks, error)
|
2022-07-06 05:08:21 +00:00
|
|
|
// GetWebhookByID to get webhook by id
|
2022-07-10 16:19:33 +00:00
|
|
|
GetWebhookByID(ctx context.Context, webhookID string) (*model.Webhook, error)
|
2022-07-09 05:51:32 +00:00
|
|
|
// GetWebhookByEventName to get webhook by event_name
|
2023-03-26 01:50:45 +00:00
|
|
|
GetWebhookByEventName(ctx context.Context, eventName string) ([]*model.Webhook, error)
|
2022-07-06 05:08:21 +00:00
|
|
|
// DeleteWebhook to delete webhook
|
2022-07-10 16:19:33 +00:00
|
|
|
DeleteWebhook(ctx context.Context, webhook *model.Webhook) error
|
2022-07-06 05:08:21 +00:00
|
|
|
|
|
|
|
// AddWebhookLog to add webhook log
|
2023-07-31 11:12:11 +00:00
|
|
|
AddWebhookLog(ctx context.Context, webhookLog *models.WebhookLog) (*model.WebhookLog, error)
|
2022-07-06 05:08:21 +00:00
|
|
|
// ListWebhookLogs to list webhook logs
|
2023-07-31 11:12:11 +00:00
|
|
|
ListWebhookLogs(ctx context.Context, pagination *model.Pagination, webhookID string) (*model.WebhookLogs, error)
|
2022-07-15 04:42:24 +00:00
|
|
|
|
|
|
|
// AddEmailTemplate to add EmailTemplate
|
2023-07-31 11:12:11 +00:00
|
|
|
AddEmailTemplate(ctx context.Context, emailTemplate *models.EmailTemplate) (*model.EmailTemplate, error)
|
2022-07-15 04:42:24 +00:00
|
|
|
// UpdateEmailTemplate to update EmailTemplate
|
2023-07-31 11:12:11 +00:00
|
|
|
UpdateEmailTemplate(ctx context.Context, emailTemplate *models.EmailTemplate) (*model.EmailTemplate, error)
|
2022-07-15 04:42:24 +00:00
|
|
|
// ListEmailTemplates to list EmailTemplate
|
2023-07-31 11:12:11 +00:00
|
|
|
ListEmailTemplate(ctx context.Context, pagination *model.Pagination) (*model.EmailTemplates, error)
|
2022-07-15 04:42:24 +00:00
|
|
|
// GetEmailTemplateByID to get EmailTemplate by id
|
|
|
|
GetEmailTemplateByID(ctx context.Context, emailTemplateID string) (*model.EmailTemplate, error)
|
|
|
|
// GetEmailTemplateByEventName to get EmailTemplate by event_name
|
|
|
|
GetEmailTemplateByEventName(ctx context.Context, eventName string) (*model.EmailTemplate, error)
|
|
|
|
// DeleteEmailTemplate to delete EmailTemplate
|
|
|
|
DeleteEmailTemplate(ctx context.Context, emailTemplate *model.EmailTemplate) error
|
2022-07-23 10:25:06 +00:00
|
|
|
|
2022-07-23 11:09:35 +00:00
|
|
|
// UpsertOTP to add or update otp
|
|
|
|
UpsertOTP(ctx context.Context, otp *models.OTP) (*models.OTP, error)
|
2022-07-23 10:25:06 +00:00
|
|
|
// GetOTPByEmail to get otp for a given email address
|
|
|
|
GetOTPByEmail(ctx context.Context, emailAddress string) (*models.OTP, error)
|
2023-07-12 05:54:13 +00:00
|
|
|
// GetOTPByPhoneNumber to get otp for a given phone number
|
|
|
|
GetOTPByPhoneNumber(ctx context.Context, phoneNumber string) (*models.OTP, error)
|
2022-07-23 10:25:06 +00:00
|
|
|
// DeleteOTP to delete otp
|
|
|
|
DeleteOTP(ctx context.Context, otp *models.OTP) error
|
2022-01-21 06:48:07 +00:00
|
|
|
}
|