some tweaks to mobile auth for new email verification #26
2 changed files with 61 additions and 16 deletions
40
dist/bundle.js
vendored
40
dist/bundle.js
vendored
|
@ -937,9 +937,11 @@ Object.defineProperty(exports, "__esModule", {
|
||||||
|
|
||||||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
||||||
|
|
||||||
var _lbryRedux = __webpack_require__(4);
|
var _action_types = __webpack_require__(2);
|
||||||
|
|
||||||
var _auth = __webpack_require__(1);
|
var ACTIONS = _interopRequireWildcard(_action_types);
|
||||||
|
|
||||||
|
var _lbryRedux = __webpack_require__(4);
|
||||||
|
|
||||||
var _querystring = __webpack_require__(5);
|
var _querystring = __webpack_require__(5);
|
||||||
|
|
||||||
|
@ -947,6 +949,8 @@ var _querystring2 = _interopRequireDefault(_querystring);
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
||||||
|
|
||||||
var Lbryio = {
|
var Lbryio = {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
authenticationPromise: null
|
authenticationPromise: null
|
||||||
|
@ -1083,15 +1087,33 @@ Lbryio.authenticate = function () {
|
||||||
return Lbryio.overrides.setAuthToken(status);
|
return Lbryio.overrides.setAuthToken(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
var _window2 = window,
|
// simply call the logic to create a new user, and obtain the auth token
|
||||||
store = _window2.store;
|
return new Promise(function (resolve, reject) {
|
||||||
|
Lbryio.call('user', 'new', {
|
||||||
|
auth_token: '',
|
||||||
|
language: 'en',
|
||||||
|
app_id: status.installation_id
|
||||||
|
}, 'post').then(function (response) {
|
||||||
|
if (!response.auth_token) {
|
||||||
|
throw new Error('auth_token was not set in the response');
|
||||||
|
}
|
||||||
|
|
||||||
if (store) {
|
var _window2 = window,
|
||||||
store.dispatch((0, _auth.doGenerateAuthToken)(status.installation_id));
|
store = _window2.store;
|
||||||
return resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
return reject();
|
if (store) {
|
||||||
|
store.dispatch({
|
||||||
|
type: ACTIONS.GENERATE_AUTH_TOKEN_SUCCESS,
|
||||||
|
data: { authToken: response.auth_token }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Lbryio.authToken = response.auth_token;
|
||||||
|
resolve(response);
|
||||||
|
}).catch(function () {
|
||||||
|
return reject();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}).then(function (user) {
|
}).then(function (user) {
|
||||||
if (!user) {
|
if (!user) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
import * as ACTIONS from 'constants/action_types';
|
||||||
import { Lbry } from 'lbry-redux';
|
import { Lbry } from 'lbry-redux';
|
||||||
import { doGenerateAuthToken } from 'redux/actions/auth';
|
|
||||||
import querystring from 'querystring';
|
import querystring from 'querystring';
|
||||||
|
|
||||||
const Lbryio = {
|
const Lbryio = {
|
||||||
|
@ -128,13 +128,36 @@ Lbryio.authenticate = () => {
|
||||||
return Lbryio.overrides.setAuthToken(status);
|
return Lbryio.overrides.setAuthToken(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { store } = window;
|
// simply call the logic to create a new user, and obtain the auth token
|
||||||
if (store) {
|
return new Promise((res, rej) => {
|
||||||
store.dispatch(doGenerateAuthToken(status.installation_id));
|
Lbryio.call(
|
||||||
return resolve();
|
'user',
|
||||||
}
|
'new',
|
||||||
|
{
|
||||||
|
auth_token: '',
|
||||||
|
language: 'en',
|
||||||
|
app_id: status.installation_id,
|
||||||
|
},
|
||||||
|
'post'
|
||||||
|
)
|
||||||
|
.then(response => {
|
||||||
|
if (!response.auth_token) {
|
||||||
|
throw new Error('auth_token was not set in the response');
|
||||||
|
}
|
||||||
|
|
||||||
return reject();
|
const { store } = window;
|
||||||
|
if (store) {
|
||||||
|
store.dispatch({
|
||||||
|
type: ACTIONS.GENERATE_AUTH_TOKEN_SUCCESS,
|
||||||
|
data: { authToken: response.auth_token },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Lbryio.authToken = response.auth_token;
|
||||||
|
res(response);
|
||||||
|
})
|
||||||
|
.catch(() => rej());
|
||||||
|
});
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.then(user => {
|
.then(user => {
|
||||||
|
|
Loading…
Reference in a new issue