Merge branch 'hack/log' of github.com:edx/frontend-app-account into hack/log

This commit is contained in:
julianajlk
2020-02-13 15:18:55 -05:00
8 changed files with 84 additions and 17 deletions

15
package-lock.json generated
View File

@@ -1157,9 +1157,9 @@
}
},
"@edx/frontend-platform": {
"version": "1.1.14",
"resolved": "https://registry.npmjs.org/@edx/frontend-platform/-/frontend-platform-1.1.14.tgz",
"integrity": "sha512-wEKKNcjKVNCHL0rgdXIlCF0dwRZc9kuuip2At7+LZ2CxPGJc3s4WGgcsA5yO16YjG2RV+gh2aZV5B/8aczM3Bw==",
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@edx/frontend-platform/-/frontend-platform-1.2.0.tgz",
"integrity": "sha512-fy3ergsRxozDofUyNvY62KU1+rZt6kZVdiSovMWYGGV7QYNYLnjyajfyb1gRhsnnRa6uubuIqcQOsH3AeLE4eg==",
"requires": {
"@cospired/i18n-iso-languages": "2.1.1",
"axios": "0.18.1",
@@ -1180,7 +1180,7 @@
"form-urlencoded": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/form-urlencoded/-/form-urlencoded-4.1.1.tgz",
"integrity": "sha512-q4SOWDgKw2Mmec2HNYzTNr/7ZXecEkO9QOwzpzx6q9HR+z+no6CsDFpAELdiyk7G3fUV5WvKy57utZxKgleqhg=="
"integrity": "sha1-Nv/xWCFoRT1XrYnVUAhbPJ3pv4I="
}
}
},
@@ -14603,7 +14603,7 @@
"pubsub-js": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/pubsub-js/-/pubsub-js-1.7.0.tgz",
"integrity": "sha512-Pb68P9qFZxnvDipHMuj9oT1FoIgBcXJ9C9eWdHCLZAnulaUoJ3+Y87RhGMYilWpun6DMWVmvK70T4RP4drZMSA=="
"integrity": "sha1-7Kl/mkIXvvYrLTqqFVIAUmDMLkk="
},
"pump": {
"version": "3.0.0",
@@ -14734,8 +14734,7 @@
"querystring": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz",
"integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=",
"dev": true
"integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA="
},
"querystring-es3": {
"version": "0.2.1",
@@ -14950,7 +14949,7 @@
"react-intl": {
"version": "2.9.0",
"resolved": "https://registry.npmjs.org/react-intl/-/react-intl-2.9.0.tgz",
"integrity": "sha512-27jnDlb/d2A7mSJwrbOBnUgD+rPep+abmoJE511Tf8BnoONIAUehy/U1zZCHGO17mnOwMWxqN4qC0nW11cD6rA==",
"integrity": "sha1-yXxdF9RxjxV1/b1adp+WAYo7GEM=",
"requires": {
"hoist-non-react-statics": "^3.3.0",
"intl-format-cache": "^2.0.5",

View File

@@ -31,7 +31,7 @@
"dependencies": {
"@edx/frontend-component-footer": "10.0.7",
"@edx/frontend-component-header": "2.0.5",
"@edx/frontend-platform": "1.1.14",
"@edx/frontend-platform": "1.2.0",
"@edx/paragon": "7.1.5",
"@fortawesome/fontawesome-svg-core": "1.2.27",
"@fortawesome/free-brands-svg-icons": "5.8.2",
@@ -55,6 +55,7 @@
"memoize-one": "5.1.1",
"newrelic": "5.13.1",
"prop-types": "15.7.2",
"querystring": "0.2.0",
"react": "16.10.2",
"react-dom": "16.10.2",
"react-redux": "7.1.3",

View File

@@ -8,7 +8,7 @@ import countryList from './countryList';
import { registerNewUser } from './data/actions';
class RegistrationPage extends React.Component {
export class RegistrationPage extends React.Component {
state = {
email: '',
name: '',

View File

@@ -1,6 +1,7 @@
import { AsyncActionType } from './utils';
export const REGISTER_NEW_USER = new AsyncActionType('REGISTRATION', 'REGISTER_NEW_USER');
export const LOGIN_REQUEST = new AsyncActionType('LOGIN', 'REQUEST');
// Register
@@ -22,3 +23,19 @@ export const registerNewUserFailure = () => ({
});
// Login
export const loginRequest = registrationInfo => ({
type: LOGIN_REQUEST.BASE,
payload: { registrationInfo },
});
export const loginRequestBegin = () => ({
type: LOGIN_REQUEST.BEGIN,
});
export const loginRequestSuccess = () => ({
type: LOGIN_REQUEST.SUCCESS,
});
export const loginRequestFailure = () => ({
type: LOGIN_REQUEST.FAILURE,
});

View File

@@ -1,5 +1,6 @@
import {
REGISTER_NEW_USER,
LOGIN_REQUEST,
} from './actions';
export const defaultState = {
@@ -20,6 +21,18 @@ const reducer = (state = defaultState, action) => {
return {
...state,
};
case LOGIN_REQUEST.BEGIN:
return {
...state,
};
case LOGIN_REQUEST.SUCCESS:
return {
...state,
};
case LOGIN_REQUEST.FAILURE:
return {
...state,
};
default:
return state;
}

View File

@@ -6,6 +6,10 @@ import {
registerNewUserBegin,
registerNewUserFailure,
registerNewUserSuccess,
LOGIN_REQUEST,
loginRequestBegin,
loginRequestFailure,
loginRequestSuccess,
} from './actions';
@@ -25,6 +29,20 @@ export function* handleNewUserRegistration(action) {
}
}
export function* handleLoginRequest(action) {
try {
yield put(loginRequestBegin());
yield call(postNewUser, action.payload.registrationInfo);
yield put(loginRequestSuccess());
} catch (e) {
yield put(loginRequestFailure());
throw e;
}
}
export default function* saga() {
yield takeEvery(REGISTER_NEW_USER.BASE, handleNewUserRegistration);
yield takeEvery(LOGIN_REQUEST.BASE, handleLoginRequest);
}

View File

@@ -1,16 +1,35 @@
import { getConfig } from '@edx/frontend-platform';
import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';
import { getHttpClient } from '@edx/frontend-platform/auth';
import querystring from 'querystring';
export default async function postNewUser(registrationInformation) {
export async function postNewUser(registrationInformation) {
const requestConfig = {
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
};
console.log('rickie is fucken baller');
const { data } = await getAuthenticatedHttpClient()
const { data } = await getHttpClient()
.post(
`${getConfig().LMS_BASE_URL}user_api/v1/account/registration/`,
registrationInformation,
`${getConfig().LMS_BASE_URL}/user_api/v1/account/registration/`,
querystring.stringify(registrationInformation),
requestConfig,
)
.catch((e) => {
console.log('You messed up');
throw (e);
});
return data;
}
export async function login(creds) {
const requestConfig = {
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
};
const { data } = await getHttpClient()
.post(
`${getConfig().LMS_BASE_URL}/user_api/v1/account/registration/`,
creds,
requestConfig,
)
.catch((e) => {

View File

@@ -1,4 +1,4 @@
export { LoginPage } from './LoginPage';
export { default as LoginPage } from './LoginPage';
export { RegistrationPage } from './RegistrationPage';
export { default as reducer } from './data/reducers';
export { default as saga } from './data/sagas';