orbis auth

This commit is contained in:
willyb321
2018-08-01 14:14:30 +10:00
parent 736c700aa0
commit c37c6983c3
2 changed files with 11 additions and 24 deletions

View File

@@ -73,6 +73,7 @@ export default class ModalOrbis extends TranslatedComponent {
* @return {React.Component} Modal Content
*/
render() {
const API_ORBIS_REGISTER = 'https://login.willb.info/signup?client_id=a555021d-17d2-4b4e-8f16-f831d8add0f5&scope=openid profile email address phone offline_access&response_type=code&passReqToCallback=true&redirect_uri=https%3A%2F%2Forbis.zone%3A3030%2Fapi%2Fauth%2Fcb';
let translate = this.context.language.translate;
this.orbisPasswordHandler = this.orbisPasswordHandler.bind(this);
this.orbisUsername = this.orbisUsername.bind(this);
@@ -81,13 +82,11 @@ export default class ModalOrbis extends TranslatedComponent {
return <div className='modal' onClick={ (e) => e.stopPropagation() }>
<h2>{translate('permalink')}</h2>
<br/>
<h3>{translate('orbis email')}</h3>
<input defaultValue={this.state.orbisCreds.email} size={40} onChange={this.orbisUsername} onFocus={ (e) => e.target.select() }/>
<a className='button' href="https://orbis.zone/api/auth">Log in to Orbis</a>
<br/><br/>
<h3>{translate('orbis password')}</h3>
<input defaultValue={this.state.orbisCreds.password} size={40} onChange={this.orbisPasswordHandler} type={'password'} onFocus={ (e) => e.target.select() }/>
<a className='button' href={API_ORBIS_REGISTER}>Sign up to Orbis</a>
<br/><br/>
<h3 >{translate('shortened')}</h3>
<h3 >{translate('Orbis link')}</h3>
<input value={this.state.orbisUrl} readOnly size={25} onFocus={ (e) => e.target.select() }/>
<br/><br/>
<p>Orbis.zone is currently in a trial period, and may be wiped at any time as development progresses. Some elements are also still placeholders.</p>

View File

@@ -95,9 +95,7 @@ function orbisShorten(url, success, error) {
}
}
const API_ORBIS = 'https://orbis.zone/api/builds/add';
const API_ORBIS_LOGIN = 'https://orbis.zone/api/login';
const API_ORBIS = 'http://localhost:3030/api/builds/add';
/**
* Upload to Orbis
* @param {object} ship The URL to shorten
@@ -109,26 +107,16 @@ export function orbisUpload(ship, creds) {
if (window.navigator.onLine) {
try {
agent
.post(API_ORBIS_LOGIN)
.send(creds)
.redirects(0)
.post(API_ORBIS)
.withCredentials()
.end(function(err) {
.redirects(0)
.set('Content-Type', 'application/json')
.send(ship)
.end(function(err, response) {
if (err) {
reject('Bad Request');
} else {
agent
.post(API_ORBIS)
.withCredentials()
.set('Content-Type', 'application/json')
.send(ship)
.end(function(err, response) {
if (err) {
reject('Bad Request');
} else {
resolve(response.body.link);
}
});
resolve(response.body.link);
}
});
} catch (e) {