Rename LocalLogin -> BetaLogin
This commit is contained in:
parent
59d5376f60
commit
e5b0fe539f
|
|
@ -102,6 +102,34 @@
|
||||||
"deprecationReason": null
|
"deprecationReason": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"name": "betaLogin",
|
||||||
|
"description": null,
|
||||||
|
"args": [
|
||||||
|
{
|
||||||
|
"name": "input",
|
||||||
|
"description": null,
|
||||||
|
"type": {
|
||||||
|
"kind": "NON_NULL",
|
||||||
|
"name": null,
|
||||||
|
"ofType": {
|
||||||
|
"kind": "INPUT_OBJECT",
|
||||||
|
"name": "BetaLoginInput",
|
||||||
|
"ofType": null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"defaultValue": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"type": {
|
||||||
|
"kind": "OBJECT",
|
||||||
|
"name": "BetaLoginPayload",
|
||||||
|
"ofType": null
|
||||||
|
},
|
||||||
|
"isDeprecated": false,
|
||||||
|
"deprecationReason": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "__debug",
|
||||||
"description": null,
|
"description": null,
|
||||||
"args": [],
|
"args": [],
|
||||||
"type": {
|
"type": {
|
||||||
|
|
@ -294,22 +322,6 @@
|
||||||
"isDeprecated": false,
|
"isDeprecated": false,
|
||||||
"deprecationReason": null
|
"deprecationReason": null
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "errors",
|
|
||||||
"description": null,
|
|
||||||
"args": [],
|
|
||||||
"type": {
|
|
||||||
"kind": "LIST",
|
|
||||||
"name": null,
|
|
||||||
"ofType": {
|
|
||||||
"kind": "OBJECT",
|
|
||||||
"name": "LoginError",
|
|
||||||
"ofType": null
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"isDeprecated": false,
|
|
||||||
"deprecationReason": null
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "clientMutationId",
|
"name": "clientMutationId",
|
||||||
"description": null,
|
"description": null,
|
||||||
|
|
@ -328,29 +340,6 @@
|
||||||
"enumValues": null,
|
"enumValues": null,
|
||||||
"possibleTypes": null
|
"possibleTypes": null
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"kind": "OBJECT",
|
|
||||||
"name": "LoginError",
|
|
||||||
"description": null,
|
|
||||||
"fields": [
|
|
||||||
{
|
|
||||||
"name": "field",
|
|
||||||
"description": null,
|
|
||||||
"args": [],
|
|
||||||
"type": {
|
|
||||||
"kind": "SCALAR",
|
|
||||||
"name": "String",
|
|
||||||
"ofType": null
|
|
||||||
},
|
|
||||||
"isDeprecated": false,
|
|
||||||
"deprecationReason": null
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"inputFields": null,
|
|
||||||
"interfaces": [],
|
|
||||||
"enumValues": null,
|
|
||||||
"possibleTypes": null
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"kind": "INPUT_OBJECT",
|
"kind": "INPUT_OBJECT",
|
||||||
"name": "LoginInput",
|
"name": "LoginInput",
|
||||||
|
|
@ -382,6 +371,94 @@
|
||||||
"enumValues": null,
|
"enumValues": null,
|
||||||
"possibleTypes": null
|
"possibleTypes": null
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"kind": "OBJECT",
|
||||||
|
"name": "BetaLoginPayload",
|
||||||
|
"description": null,
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"name": "success",
|
||||||
|
"description": null,
|
||||||
|
"args": [],
|
||||||
|
"type": {
|
||||||
|
"kind": "SCALAR",
|
||||||
|
"name": "Boolean",
|
||||||
|
"ofType": null
|
||||||
|
},
|
||||||
|
"isDeprecated": false,
|
||||||
|
"deprecationReason": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "message",
|
||||||
|
"description": null,
|
||||||
|
"args": [],
|
||||||
|
"type": {
|
||||||
|
"kind": "SCALAR",
|
||||||
|
"name": "String",
|
||||||
|
"ofType": null
|
||||||
|
},
|
||||||
|
"isDeprecated": false,
|
||||||
|
"deprecationReason": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "clientMutationId",
|
||||||
|
"description": null,
|
||||||
|
"args": [],
|
||||||
|
"type": {
|
||||||
|
"kind": "SCALAR",
|
||||||
|
"name": "String",
|
||||||
|
"ofType": null
|
||||||
|
},
|
||||||
|
"isDeprecated": false,
|
||||||
|
"deprecationReason": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"inputFields": null,
|
||||||
|
"interfaces": [],
|
||||||
|
"enumValues": null,
|
||||||
|
"possibleTypes": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "INPUT_OBJECT",
|
||||||
|
"name": "BetaLoginInput",
|
||||||
|
"description": null,
|
||||||
|
"fields": null,
|
||||||
|
"inputFields": [
|
||||||
|
{
|
||||||
|
"name": "usernameInput",
|
||||||
|
"description": null,
|
||||||
|
"type": {
|
||||||
|
"kind": "SCALAR",
|
||||||
|
"name": "String",
|
||||||
|
"ofType": null
|
||||||
|
},
|
||||||
|
"defaultValue": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "passwordInput",
|
||||||
|
"description": null,
|
||||||
|
"type": {
|
||||||
|
"kind": "SCALAR",
|
||||||
|
"name": "String",
|
||||||
|
"ofType": null
|
||||||
|
},
|
||||||
|
"defaultValue": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "clientMutationId",
|
||||||
|
"description": null,
|
||||||
|
"type": {
|
||||||
|
"kind": "SCALAR",
|
||||||
|
"name": "String",
|
||||||
|
"ofType": null
|
||||||
|
},
|
||||||
|
"defaultValue": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"interfaces": null,
|
||||||
|
"enumValues": null,
|
||||||
|
"possibleTypes": null
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"kind": "OBJECT",
|
"kind": "OBJECT",
|
||||||
"name": "DjangoDebug",
|
"name": "DjangoDebug",
|
||||||
|
|
@ -1490,5 +1567,4 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,14 +32,14 @@ import '@iam4x/cypress-graphql-mock';
|
||||||
|
|
||||||
Cypress.Commands.add('apolloLogin', (username, password) => {
|
Cypress.Commands.add('apolloLogin', (username, password) => {
|
||||||
const payload = {
|
const payload = {
|
||||||
'operationName': 'LocalLogin',
|
'operationName': 'BetaLogin',
|
||||||
'variables': {
|
'variables': {
|
||||||
'input': {
|
'input': {
|
||||||
'usernameInput': username,
|
'usernameInput': username,
|
||||||
'passwordInput': password
|
'passwordInput': password
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'query': 'mutation LocalLogin($input: LocalLoginInput!) {\n localLogin(input: $input) {\n success\n errors {\n field\n __typename\n }\n __typename\n }\n}\n'
|
'query': 'mutation BetaLogin($input: BetaLoginInput!) {\n betaLogin(input: $input) {\n success\n errors {\n field\n __typename\n }\n __typename\n }\n}\n'
|
||||||
};
|
};
|
||||||
|
|
||||||
cy.request({
|
cy.request({
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
mutation BetaLogin($input: BetaLoginInput!) {
|
||||||
|
betaLogin(input: $input) {
|
||||||
|
success
|
||||||
|
message
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -2,8 +2,5 @@ mutation Login($input: LoginInput!) {
|
||||||
login(input: $input) {
|
login(input: $input) {
|
||||||
success
|
success
|
||||||
message
|
message
|
||||||
errors {
|
|
||||||
field
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
mutation LocalLogin($input: LocalLoginInput!) {
|
|
||||||
localLogin(input: $input) {
|
|
||||||
success
|
|
||||||
message
|
|
||||||
errors {
|
|
||||||
field
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -71,7 +71,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import LOGIN_LOCAL_MUTATION from '@/graphql/gql/mutations/loginLocal.gql';
|
import BETA_LOGIN_MUTATION from '@/graphql/gql/mutations/betaLogin.gql';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {},
|
components: {},
|
||||||
|
|
@ -84,7 +84,7 @@ export default {
|
||||||
if (result) {
|
if (result) {
|
||||||
this.$apollo.mutate({
|
this.$apollo.mutate({
|
||||||
client: 'publicClient',
|
client: 'publicClient',
|
||||||
mutation: LOGIN_LOCAL_MUTATION,
|
mutation: BETA_LOGIN_MUTATION,
|
||||||
variables: {
|
variables: {
|
||||||
input: {
|
input: {
|
||||||
usernameInput: this.email,
|
usernameInput: this.email,
|
||||||
|
|
@ -95,12 +95,12 @@ export default {
|
||||||
store,
|
store,
|
||||||
{
|
{
|
||||||
data: {
|
data: {
|
||||||
localLogin
|
betaLogin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
if (localLogin.success) {
|
if (betaLogin.success) {
|
||||||
const redirectUrl = that.$route.query.redirect ? that.$route.query.redirect : '/'
|
const redirectUrl = that.$route.query.redirect ? that.$route.query.redirect : '/'
|
||||||
that.$router.push(redirectUrl);
|
that.$router.push(redirectUrl);
|
||||||
}
|
}
|
||||||
|
|
@ -28,7 +28,7 @@ import surveyPage from '@/pages/survey'
|
||||||
import styleGuidePage from '@/pages/styleguide'
|
import styleGuidePage from '@/pages/styleguide'
|
||||||
import moduleRoom from '@/pages/moduleRoom'
|
import moduleRoom from '@/pages/moduleRoom'
|
||||||
import login from '@/pages/login'
|
import login from '@/pages/login'
|
||||||
import loginLocal from '@/pages/login-local'
|
import betaLogin from '@/pages/beta-login'
|
||||||
import hello from '@/pages/hello'
|
import hello from '@/pages/hello'
|
||||||
import registration from '@/pages/registration'
|
import registration from '@/pages/registration'
|
||||||
import waitForClass from '@/pages/waitForClass'
|
import waitForClass from '@/pages/waitForClass'
|
||||||
|
|
@ -68,7 +68,7 @@ const routes = [
|
||||||
{
|
{
|
||||||
path: '/beta-login',
|
path: '/beta-login',
|
||||||
name: 'betaLogin',
|
name: 'betaLogin',
|
||||||
component: loginLocal,
|
component: betaLogin,
|
||||||
meta: {
|
meta: {
|
||||||
layout: 'public',
|
layout: 'public',
|
||||||
public: true
|
public: true
|
||||||
|
|
|
||||||
|
|
@ -376,7 +376,7 @@ TASKBASE_SUPERPASSWORD = os.environ.get("TASKBASE_SUPERPASSWORD")
|
||||||
TASKBASE_BASEURL = os.environ.get("TASKBASE_BASEURL")
|
TASKBASE_BASEURL = os.environ.get("TASKBASE_BASEURL")
|
||||||
|
|
||||||
|
|
||||||
ALLOW_LOCAL_LOGIN = True
|
ALLOW_BETA_LOGIN = True
|
||||||
|
|
||||||
# HEP
|
# HEP
|
||||||
HEP_ADMIN_USER = "myskillbox"
|
HEP_ADMIN_USER = "myskillbox"
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ class ApiAccessTestCase(TestCase):
|
||||||
self.assertEqual(response.url, '/login?next=/api/graphql/')
|
self.assertEqual(response.url, '/login?next=/api/graphql/')
|
||||||
|
|
||||||
def test_graphqlEndpoint_shouldBeAccessibleWithLogin(self):
|
def test_graphqlEndpoint_shouldBeAccessibleWithLogin(self):
|
||||||
user = UserFactory(username='admin')
|
UserFactory(username='admin')
|
||||||
|
|
||||||
c = Client()
|
c = Client()
|
||||||
c.login(username='admin', password='test')
|
c.login(username='admin', password='test')
|
||||||
|
|
@ -31,14 +31,11 @@ class ApiAccessTestCase(TestCase):
|
||||||
def test_publicGraphqlEndpoint_shouldBeAccessibleWithoutLogin(self):
|
def test_publicGraphqlEndpoint_shouldBeAccessibleWithoutLogin(self):
|
||||||
|
|
||||||
query= json.dumps({
|
query= json.dumps({
|
||||||
'operationName': 'LocalLogin',
|
'operationName': 'BetaLogin',
|
||||||
'query': '''
|
'query': '''
|
||||||
mutation LocalLogin($input: LocalLoginInput!){
|
mutation BetaLogin($input: BetaLoginInput!){
|
||||||
localLogin(input: $input) {
|
betaLogin(input: $input) {
|
||||||
success
|
success
|
||||||
errors {
|
|
||||||
field
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
''',
|
''',
|
||||||
|
|
|
||||||
|
|
@ -17,22 +17,17 @@ from core.hep_client import HepClient, HepClientUnauthorizedException, HepClient
|
||||||
from users.user_signup_login_handler import handle_user_and_verify_products, UNKNOWN_ERROR, EMAIL_NOT_VERIFIED
|
from users.user_signup_login_handler import handle_user_and_verify_products, UNKNOWN_ERROR, EMAIL_NOT_VERIFIED
|
||||||
|
|
||||||
|
|
||||||
class LoginError(graphene.ObjectType):
|
class BetaLogin(relay.ClientIDMutation):
|
||||||
field = graphene.String()
|
|
||||||
|
|
||||||
|
|
||||||
class LocalLogin(relay.ClientIDMutation):
|
|
||||||
class Input:
|
class Input:
|
||||||
username_input = graphene.String()
|
username_input = graphene.String()
|
||||||
password_input = graphene.String()
|
password_input = graphene.String()
|
||||||
|
|
||||||
success = graphene.Boolean()
|
success = graphene.Boolean()
|
||||||
message = graphene.String()
|
message = graphene.String()
|
||||||
errors = graphene.List(LoginError) # todo: change for consistency
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def mutate_and_get_payload(cls, root, info, **kwargs):
|
def mutate_and_get_payload(cls, root, info, **kwargs):
|
||||||
if settings.ALLOW_LOCAL_LOGIN:
|
if settings.ALLOW_BETA_LOGIN:
|
||||||
password = kwargs.get('password_input')
|
password = kwargs.get('password_input')
|
||||||
username = kwargs.get('username_input')
|
username = kwargs.get('username_input')
|
||||||
user = authenticate(username=username, password=password)
|
user = authenticate(username=username, password=password)
|
||||||
|
|
@ -40,7 +35,7 @@ class LocalLogin(relay.ClientIDMutation):
|
||||||
raise Exception('invalid_credentials')
|
raise Exception('invalid_credentials')
|
||||||
login(info.context, user)
|
login(info.context, user)
|
||||||
|
|
||||||
return cls(success=True, errors=[], message='')
|
return cls(success=True, message='')
|
||||||
|
|
||||||
raise Exception('not_implemented')
|
raise Exception('not_implemented')
|
||||||
|
|
||||||
|
|
@ -51,7 +46,6 @@ class Login(relay.ClientIDMutation):
|
||||||
|
|
||||||
success = graphene.Boolean()
|
success = graphene.Boolean()
|
||||||
message = graphene.String()
|
message = graphene.String()
|
||||||
errors = graphene.List(LoginError) # todo: change for consistency
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def mutate_and_get_payload(cls, root, info, **kwargs):
|
def mutate_and_get_payload(cls, root, info, **kwargs):
|
||||||
|
|
@ -75,18 +69,18 @@ class Login(relay.ClientIDMutation):
|
||||||
if status_msg:
|
if status_msg:
|
||||||
return cls.return_login_message(status_msg)
|
return cls.return_login_message(status_msg)
|
||||||
|
|
||||||
return cls(success=True, errors=[], message='success')
|
return cls(success=True, message='success')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def return_login_message(cls, message):
|
def return_login_message(cls, message):
|
||||||
if message == EMAIL_NOT_VERIFIED or message == UNKNOWN_ERROR or message == 'invalid_credentials':
|
if message == EMAIL_NOT_VERIFIED or message == UNKNOWN_ERROR or message == 'invalid_credentials':
|
||||||
raise Exception(message)
|
raise Exception(message)
|
||||||
return cls(success=True, errors=[], message=message)
|
return cls(success=True, message=message)
|
||||||
|
|
||||||
|
|
||||||
class UserMutations:
|
class UserMutations:
|
||||||
login = Login.Field()
|
login = Login.Field()
|
||||||
local_login = LocalLogin.Field()
|
beta_login = BetaLogin.Field()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ from core.factories import UserFactory
|
||||||
from users.models import Role
|
from users.models import Role
|
||||||
|
|
||||||
|
|
||||||
class LocalLoginTests(TestCase):
|
class BetaLoginTests(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.user = UserFactory(username='aschi@iterativ.ch', email='aschi@iterativ.ch')
|
self.user = UserFactory(username='aschi@iterativ.ch', email='aschi@iterativ.ch')
|
||||||
self.teacher_role = Role.objects.create(key=Role.objects.TEACHER_KEY, name="Teacher Role")
|
self.teacher_role = Role.objects.create(key=Role.objects.TEACHER_KEY, name="Teacher Role")
|
||||||
|
|
@ -31,12 +31,9 @@ class LocalLoginTests(TestCase):
|
||||||
|
|
||||||
def make_login_mutation(self, username, password):
|
def make_login_mutation(self, username, password):
|
||||||
mutation = '''
|
mutation = '''
|
||||||
mutation LocalLogin($input: LocalLoginInput!){
|
mutation BetaLogin($input: BetaLoginInput!){
|
||||||
localLogin(input: $input) {
|
betaLogin(input: $input) {
|
||||||
success
|
success
|
||||||
errors {
|
|
||||||
field
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
|
|
@ -54,7 +51,7 @@ class LocalLoginTests(TestCase):
|
||||||
self.user.save()
|
self.user.save()
|
||||||
|
|
||||||
result = self.make_login_mutation(self.user.email, password)
|
result = self.make_login_mutation(self.user.email, password)
|
||||||
self.assertTrue(result.get('data').get('localLogin').get('success'))
|
self.assertTrue(result.get('data').get('betaLogin').get('success'))
|
||||||
self.assertTrue(self.user.is_authenticated)
|
self.assertTrue(self.user.is_authenticated)
|
||||||
|
|
||||||
def test_user_cannot_login_with_invalid_password(self):
|
def test_user_cannot_login_with_invalid_password(self):
|
||||||
|
|
|
||||||
|
|
@ -49,9 +49,6 @@ class LoginTests(TestCase):
|
||||||
login(input: $input) {
|
login(input: $input) {
|
||||||
success
|
success
|
||||||
message
|
message
|
||||||
errors {
|
|
||||||
field
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue