client/src/actions/authActions.js
author ymh <ymh.work@gmail.com>
Fri, 30 Nov 2018 10:53:15 +0100
changeset 183 f8f3af9e5c83
parent 129 d48946d164c6
child 199 c78d579f4b55
permissions -rw-r--r--
Change the settings to avoid using Session authentication for rest framework as it raise exceptions in case client and backend are on the same domain On the filter, adapt to take into account new version of django_filters
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
44
3b20e2b584fe Introduce authentication through API.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
     1
import * as types from '../constants/actionTypes';
3b20e2b584fe Introduce authentication through API.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
     2
3b20e2b584fe Introduce authentication through API.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
     3
export const loginSubmit = (username, password) => {
3b20e2b584fe Introduce authentication through API.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
     4
  return {
3b20e2b584fe Introduce authentication through API.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
     5
    type: types.AUTH_LOGIN_SUBMIT,
3b20e2b584fe Introduce authentication through API.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
     6
    username,
3b20e2b584fe Introduce authentication through API.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
     7
    password
3b20e2b584fe Introduce authentication through API.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
     8
  };
3b20e2b584fe Introduce authentication through API.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
     9
}
52
96f8a4a59bd9 Implement logout.
Alexandre Segura <mex.zktk@gmail.com>
parents: 44
diff changeset
    10
96f8a4a59bd9 Implement logout.
Alexandre Segura <mex.zktk@gmail.com>
parents: 44
diff changeset
    11
export const logout = () => {
96f8a4a59bd9 Implement logout.
Alexandre Segura <mex.zktk@gmail.com>
parents: 44
diff changeset
    12
  return {
96f8a4a59bd9 Implement logout.
Alexandre Segura <mex.zktk@gmail.com>
parents: 44
diff changeset
    13
    type: types.AUTH_LOGOUT
96f8a4a59bd9 Implement logout.
Alexandre Segura <mex.zktk@gmail.com>
parents: 44
diff changeset
    14
  };
96f8a4a59bd9 Implement logout.
Alexandre Segura <mex.zktk@gmail.com>
parents: 44
diff changeset
    15
}
89
06f609adfbf8 Add registration page.
Alexandre Segura <mex.zktk@gmail.com>
parents: 52
diff changeset
    16
06f609adfbf8 Add registration page.
Alexandre Segura <mex.zktk@gmail.com>
parents: 52
diff changeset
    17
export const registerSubmit = (username, email, password1, password2) => {
06f609adfbf8 Add registration page.
Alexandre Segura <mex.zktk@gmail.com>
parents: 52
diff changeset
    18
  return {
06f609adfbf8 Add registration page.
Alexandre Segura <mex.zktk@gmail.com>
parents: 52
diff changeset
    19
    type: types.AUTH_REGISTER_SUBMIT,
06f609adfbf8 Add registration page.
Alexandre Segura <mex.zktk@gmail.com>
parents: 52
diff changeset
    20
    username,
06f609adfbf8 Add registration page.
Alexandre Segura <mex.zktk@gmail.com>
parents: 52
diff changeset
    21
    email,
06f609adfbf8 Add registration page.
Alexandre Segura <mex.zktk@gmail.com>
parents: 52
diff changeset
    22
    password1,
06f609adfbf8 Add registration page.
Alexandre Segura <mex.zktk@gmail.com>
parents: 52
diff changeset
    23
    password2
06f609adfbf8 Add registration page.
Alexandre Segura <mex.zktk@gmail.com>
parents: 52
diff changeset
    24
  };
06f609adfbf8 Add registration page.
Alexandre Segura <mex.zktk@gmail.com>
parents: 52
diff changeset
    25
}
100
6fd752d98933 Introduce group creation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 89
diff changeset
    26
6fd752d98933 Introduce group creation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 89
diff changeset
    27
export const createGroup = (name) => {
6fd752d98933 Introduce group creation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 89
diff changeset
    28
  const group = {
6fd752d98933 Introduce group creation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 89
diff changeset
    29
    name
6fd752d98933 Introduce group creation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 89
diff changeset
    30
  };
6fd752d98933 Introduce group creation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 89
diff changeset
    31
6fd752d98933 Introduce group creation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 89
diff changeset
    32
  return {
6fd752d98933 Introduce group creation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 89
diff changeset
    33
    type: types.GROUP_CREATE_ASYNC,
6fd752d98933 Introduce group creation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 89
diff changeset
    34
    group,
6fd752d98933 Introduce group creation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 89
diff changeset
    35
  };
6fd752d98933 Introduce group creation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 89
diff changeset
    36
}
107
e6f85e26b08c Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents: 100
diff changeset
    37
e6f85e26b08c Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents: 100
diff changeset
    38
129
d48946d164c6 Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents: 107
diff changeset
    39
export const resetAll = () => {
d48946d164c6 Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents: 107
diff changeset
    40
  return { type: types.SYNC_RESET_ALL }
107
e6f85e26b08c Confirm logout when pending requests, try to purge offline.outbox
Alexandre Segura <mex.zktk@gmail.com>
parents: 100
diff changeset
    41
}