Skip to content
Snippets Groups Projects
Commit 60442f8e authored by Hangzhi Yu's avatar Hangzhi Yu
Browse files

Directly check if shared secret is correct in mutation

parent 3d6464a8
No related branches found
No related tags found
1 merge request!2Frontend
......@@ -51,8 +51,11 @@
sharedSecret: this.sharedSecret,
},
}).then((data) => {
this.sharedSecretStatus = data.data.submitSharedSecret.correct;
if (!this.sharedSecretStatus) {
this.showError = true;
}
this.loading = false;
this.$apollo.queries.sharedSecretStatus.refetch();
});
},
},
......@@ -69,9 +72,7 @@
sharedSecretStatus: {
query: gqlSharedSecretStatus,
result ({ data, loading, networkStatus }) {
if (!loading && !data?.sharedSecretStatus && !this.initial) {
this.showError = true;
} else if (!loading) {
if (!loading) {
this.initial = false;
}
},
......
mutation gqlSubmitSharedSecret($sharedSecret: String!) {
submitSharedSecret(sharedSecret: $sharedSecret) {
ok
correct
}
}
......
......@@ -11,12 +11,14 @@ class SubmitSharedSecretMutation(graphene.Mutation):
class Arguments:
shared_secret = graphene.String(required=True) # noqa
ok = graphene.Boolean()
correct = graphene.Boolean()
@classmethod
def mutate(cls, root, info, shared_secret): # noqa
info.context.session["maka_shared_secret_correct"] = check_password(shared_secret, get_site_preferences()["maka__shared_secret"])
return cls(ok=True)
if not info.context.session.get("maka_shared_secret_correct"):
info.context.session["maka_shared_secret_correct"] = check_password(shared_secret, get_site_preferences()["maka__shared_secret"])
return cls(correct=info.context.session.get("maka_shared_secret_correct"))
return cls(correct=True)
class SharedSecretObjectType(DjangoObjectType):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment