2021-07-18 04:22:54 +00:00
|
|
|
package resolvers
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
|
2021-07-23 16:27:44 +00:00
|
|
|
"github.com/authorizerdev/authorizer/server/db"
|
|
|
|
"github.com/authorizerdev/authorizer/server/graph/model"
|
|
|
|
"github.com/authorizerdev/authorizer/server/utils"
|
2021-07-18 04:22:54 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func VerificationRequests(ctx context.Context) ([]*model.VerificationRequest, error) {
|
|
|
|
gc, err := utils.GinContextFromContext(ctx)
|
|
|
|
var res []*model.VerificationRequest
|
|
|
|
if err != nil {
|
|
|
|
return res, err
|
|
|
|
}
|
|
|
|
|
|
|
|
if !utils.IsSuperAdmin(gc) {
|
|
|
|
return res, fmt.Errorf("unauthorized")
|
|
|
|
}
|
|
|
|
|
|
|
|
verificationRequests, err := db.Mgr.GetVerificationRequests()
|
|
|
|
if err != nil {
|
|
|
|
return res, err
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, verificationRequest := range verificationRequests {
|
|
|
|
res = append(res, &model.VerificationRequest{
|
2021-07-18 07:26:17 +00:00
|
|
|
ID: fmt.Sprintf("%d", verificationRequest.ID),
|
|
|
|
Email: &verificationRequest.Email,
|
|
|
|
Token: &verificationRequest.Token,
|
|
|
|
Identifier: &verificationRequest.Identifier,
|
|
|
|
Expires: &verificationRequest.ExpiresAt,
|
|
|
|
CreatedAt: &verificationRequest.CreatedAt,
|
|
|
|
UpdatedAt: &verificationRequest.UpdatedAt,
|
2021-07-18 04:22:54 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
return res, nil
|
|
|
|
}
|