Init password reset after registration
This commit is contained in:
parent
836cd63cfd
commit
148b2cae3d
|
|
@ -129,7 +129,7 @@ export default {
|
|||
let that = this;
|
||||
if (result) {
|
||||
this.$apollo.mutate({
|
||||
// client: 'publicClient',
|
||||
client: 'publicClient',
|
||||
mutation: REGISTRATION_MUTATION,
|
||||
variables: {
|
||||
input: {
|
||||
|
|
@ -149,8 +149,7 @@ export default {
|
|||
) {
|
||||
try {
|
||||
if (success) {
|
||||
const redirectUrl = that.$route.query.redirect ? that.$route.query.redirect : '/'
|
||||
that.$router.push(redirectUrl);
|
||||
that.$router.push('/set-password/done/');
|
||||
} else {
|
||||
errors.forEach(function(error) {
|
||||
switch (error.field) {
|
||||
|
|
|
|||
|
|
@ -3,9 +3,10 @@ from django.conf import settings
|
|||
from graphene_django.debug import DjangoDebug
|
||||
|
||||
from users.mutations_public import UserMutations
|
||||
from registration.mutations_public import RegistrationMutations
|
||||
|
||||
|
||||
class Mutation(UserMutations, graphene.ObjectType):
|
||||
class Mutation(UserMutations, RegistrationMutations, graphene.ObjectType):
|
||||
|
||||
if settings.DEBUG:
|
||||
debug = graphene.Field(DjangoDebug, name='__debug')
|
||||
|
|
|
|||
|
|
@ -115,6 +115,8 @@ input[type=text], input[type=password], input[type=email], select {
|
|||
|
||||
.reset__text {
|
||||
margin-bottom: 52px;
|
||||
line-height: 1.5rem;
|
||||
font-size: 1.125rem;
|
||||
}
|
||||
|
||||
.reset__form label {
|
||||
|
|
|
|||
|
|
@ -10,10 +10,11 @@
|
|||
import graphene
|
||||
from graphene import relay
|
||||
|
||||
from core.views import SetPasswordView
|
||||
from registration.models import License
|
||||
from registration.serializers import RegistrationSerializer
|
||||
from users.models import User, Role, UserRole, SchoolClass
|
||||
from users.mutations import UpdateError, FieldError
|
||||
from users.mutations_public import MutationError, FieldError
|
||||
|
||||
|
||||
class Registration(relay.ClientIDMutation):
|
||||
|
|
@ -24,7 +25,7 @@ class Registration(relay.ClientIDMutation):
|
|||
license_key_input = graphene.String()
|
||||
|
||||
success = graphene.Boolean()
|
||||
errors = graphene.List(UpdateError) # todo: change for consistency
|
||||
errors = graphene.List(MutationError) # todo: change for consistency
|
||||
|
||||
@classmethod
|
||||
def mutate_and_get_payload(cls, root, info, **kwargs):
|
||||
|
|
@ -57,11 +58,20 @@ class Registration(relay.ClientIDMutation):
|
|||
student_role = Role.objects.get(key=Role.objects.STUDENT_KEY)
|
||||
UserRole.objects.get_or_create(user=user, role=student_role)
|
||||
|
||||
password_reset_view = SetPasswordView()
|
||||
password_reset_view.request = info.context
|
||||
form = password_reset_view.form_class({'email': user.email})
|
||||
|
||||
if not form.is_valid():
|
||||
return cls(success=False, errors=form.errors)
|
||||
|
||||
password_reset_view.form_valid(form)
|
||||
|
||||
return cls(success=True)
|
||||
|
||||
errors = []
|
||||
for key, value in serializer.errors.items():
|
||||
error = UpdateError(field=key, errors=[])
|
||||
error = MutationError(field=key, errors=[])
|
||||
for field_error in serializer.errors[key]:
|
||||
error.errors.append(FieldError(code=field_error.code))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue