IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an email to s dot adaszewski at gmail dot com. User accounts are meant only to report issues and/or generate pull requests. This is a purpose-specific Git hosting for ADARED projects. Thank you for your understanding!
소스 검색

Add normal login via redirection.

master
부모
커밋
0395efc73b
3개의 변경된 파일54개의 추가작업 그리고 12개의 파일을 삭제
  1. +1
    -1
      frontend/src/js/page/wb-app.js
  2. +52
    -10
      frontend/src/js/page/wb-sign-in.js
  3. +1
    -1
      frontend/src/js/widget/wb-tabs.js

+ 1
- 1
frontend/src/js/page/wb-app.js 파일 보기

@@ -71,7 +71,7 @@ class WBApp extends Component {
<Router>
<WBLandingPage path="/" />
<WBSignIn path="/sign-in" appState={ this.state } />
<WBSignIn path="/sign-in/:mode?" appState={ this.state } />
<WBSignOut path='/sign-out' app={ this } />


+ 52
- 10
frontend/src/js/page/wb-sign-in.js 파일 보기

@@ -1,11 +1,47 @@
import { h, Component } from 'preact';
import { route } from 'preact-router';
import WBNavbar from 'wb-navbar';
import WBTabs from 'wb-tabs';
import linkState from 'linkstate';
import makeArvadosRequest from 'make-arvados-request';
class WBSignIn extends Component {
onSubmit() {
constructor(...args) {
super(...args);
const search = new URLSearchParams(window.location.search);
this.state.arvHost = window.localStorage.arvHost;
this.state.arvToken = search.get('api_token');
}
componentDidMount() {
// const arvHost = window.localStorage.arvHost;
// const arvToken = search.get('api_token');
const { arvHost, arvToken } = this.state;
if (arvHost && arvToken) {
this.state.arvHost = arvHost;
this.state.arvToken = arvToken;
this.submitToken();
}
}
submit() {
const { mode } = this.props;
if (mode === 'token')
this.submitToken();
else if (!mode || mode === 'sso')
this.submitSingleSignOn();
else
throw Error('Unsupported mode');
}
submitSingleSignOn() {
const { arvHost } = this.state;
window.localStorage.arvHost = arvHost;
window.location = 'https://' + arvHost + '/login?return_to='
+ encodeURIComponent(window.location.protocol + '//' + window.location.host + '/sign-in/token');
}
submitToken() {
let { appState } = this.props;
let { arvHost, arvToken } = this.state;
let prom = makeArvadosRequest(arvHost, arvToken, '/arvados/v1/users/current');
@@ -23,14 +59,18 @@ class WBSignIn extends Component {
});
}
render({}, { arvHost, arvToken }) {
render({ mode }, { arvHost, arvToken }) {
return (
<div>
<WBNavbar />
<div class="container my-3">
<div class="row justify-content-center">
<div class="col-6">
<h1>Sign In</h1>
<WBTabs class="my-3" tabs={ [ { name: 'SSO', isActive: (!mode || mode === 'sso') },
{ name: 'Token', isActive: (mode === 'token') } ] }
onTabChanged={ t => route(t.name === 'Token' ? '/sign-in/token' : '/sign-in/sso') } />
<form>
<div class="form-group">
<label for="arvHost">Arvados API Host</label>
@@ -39,15 +79,17 @@ class WBSignIn extends Component {
value={ arvHost }
onInput={ linkState(this, 'arvHost') } />
</div>
<div class="form-group">
<label for="arvToken">Token</label>
<input type="text" class="form-control" id="arvToken"
placeholder="Enter Arvados API Token"
value={ arvToken }
onInput={ linkState(this, 'arvToken') } />
</div>
{ mode === 'token' ? (
<div class="form-group">
<label for="arvToken">Token</label>
<input type="text" class="form-control" id="arvToken"
placeholder="Enter Arvados API Token"
value={ arvToken }
onInput={ linkState(this, 'arvToken') } />
</div>
) : null }
<button type="submit" class="btn btn-primary"
onclick={ e => { e.preventDefault(); this.onSubmit(); } }>Submit</button>
onclick={ e => { e.preventDefault(); this.submit(); } }>Submit</button>
</form>
</div>
</div>


+ 1
- 1
frontend/src/js/widget/wb-tabs.js 파일 보기

@@ -3,7 +3,7 @@ import { h, Component, VNode } from 'preact';
class WBTabs extends Component {
render({ tabs, onTabChanged }) {
return (
<ul class="nav nav-tabs">
<ul class={ 'nav nav-tabs ' + this.props.class }>
{ tabs.map((t, idx) => {
let name, isActive, isDisabled, onClick;


불러오는 중...
취소
저장