mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 19:44:21 +00:00
c970003c82
* fix: email change not possible if init state * fix: email change not possible if init state * passwordless Co-authored-by: Livio Amstutz <livio.a@gmail.com>
62 lines
2.1 KiB
Go
62 lines
2.1 KiB
Go
package auth
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/caos/zitadel/internal/api/authz"
|
|
"github.com/caos/zitadel/internal/api/grpc/object"
|
|
user_grpc "github.com/caos/zitadel/internal/api/grpc/user"
|
|
auth_pb "github.com/caos/zitadel/pkg/grpc/auth"
|
|
user_pb "github.com/caos/zitadel/pkg/grpc/user"
|
|
)
|
|
|
|
func (s *Server) ListMyPasswordless(ctx context.Context, _ *auth_pb.ListMyPasswordlessRequest) (*auth_pb.ListMyPasswordlessResponse, error) {
|
|
tokens, err := s.repo.GetMyPasswordless(ctx)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &auth_pb.ListMyPasswordlessResponse{
|
|
Result: user_grpc.WebAuthNTokensViewToPb(tokens),
|
|
}, nil
|
|
}
|
|
|
|
func (s *Server) AddMyPasswordless(ctx context.Context, _ *auth_pb.AddMyPasswordlessRequest) (*auth_pb.AddMyPasswordlessResponse, error) {
|
|
ctxData := authz.GetCtxData(ctx)
|
|
token, err := s.command.HumanAddPasswordlessSetup(ctx, ctxData.UserID, ctxData.ResourceOwner, false)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &auth_pb.AddMyPasswordlessResponse{
|
|
Key: &user_pb.WebAuthNKey{
|
|
PublicKey: token.CredentialCreationData,
|
|
},
|
|
Details: object.AddToDetailsPb(
|
|
token.Sequence,
|
|
token.ChangeDate,
|
|
token.ResourceOwner,
|
|
),
|
|
}, nil
|
|
}
|
|
|
|
func (s *Server) VerifyMyPasswordless(ctx context.Context, req *auth_pb.VerifyMyPasswordlessRequest) (*auth_pb.VerifyMyPasswordlessResponse, error) {
|
|
ctxData := authz.GetCtxData(ctx)
|
|
objectDetails, err := s.command.HumanHumanPasswordlessSetup(ctx, ctxData.UserID, ctxData.ResourceOwner, req.Verification.TokenName, "", req.Verification.PublicKeyCredential)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &auth_pb.VerifyMyPasswordlessResponse{
|
|
Details: object.DomainToChangeDetailsPb(objectDetails),
|
|
}, nil
|
|
}
|
|
|
|
func (s *Server) RemoveMyPasswordless(ctx context.Context, req *auth_pb.RemoveMyPasswordlessRequest) (*auth_pb.RemoveMyPasswordlessResponse, error) {
|
|
ctxData := authz.GetCtxData(ctx)
|
|
objectDetails, err := s.command.HumanRemovePasswordless(ctx, ctxData.UserID, req.TokenId, ctxData.ResourceOwner)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &auth_pb.RemoveMyPasswordlessResponse{
|
|
Details: object.DomainToChangeDetailsPb(objectDetails),
|
|
}, nil
|
|
}
|