[Major] now firing strolch-session-valid on session validation/login
This commit is contained in:
parent
ecc021aaba
commit
f396b45776
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "strolch-wc-auth",
|
||||
"description": "Strolch WebComponent Auth",
|
||||
"version": "0.4.4",
|
||||
"version": "0.5.0",
|
||||
"authors": "Robert von Burg",
|
||||
"keywords": [
|
||||
"strolch",
|
||||
|
@ -17,14 +17,14 @@
|
|||
"homepage": "https://github.com/4treesCH/strolch-wc-auth",
|
||||
"ignore": [],
|
||||
"dependencies": {
|
||||
"strolchjs": "4treesCH/strolchjs#^0.1.3",
|
||||
"strolchjs": "4treesCH/strolchjs#^0.1.4",
|
||||
"strolch-wc-localize-behavior": "4treesCH/strolch-wc-localize-behavior#^1.0.2",
|
||||
"paper-material": "PolymerElements/paper-material#^1.0.6",
|
||||
"paper-card": "PolymerElements/paper-card#^1.1.2",
|
||||
"paper-dialog": "PolymerElements/paper-dialog#^1.1.0",
|
||||
"paper-button": "PolymerElements/paper-button#^1.0.13",
|
||||
"iron-a11y-keys": "PolymerElements/iron-a11y-keys#^1.0.6",
|
||||
"paper-input": "PolymerElements/paper-input#^1.1.17",
|
||||
"iron-ajax": "PolymerElements/iron-ajax#^1.4.3",
|
||||
"strolch-wc-localize-behavior": "4treesCH/strolch-wc-localize-behavior#^1.0.2"
|
||||
"iron-ajax": "PolymerElements/iron-ajax#^1.4.3"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,6 +69,7 @@
|
|||
label="{{localize('password')}}"
|
||||
required
|
||||
type="password"
|
||||
on-focus="onFocus"
|
||||
auto-validate></paper-input>
|
||||
</div>
|
||||
<div class="card-actions">
|
||||
|
@ -125,12 +126,14 @@
|
|||
label="{{localize('password')}}"
|
||||
required
|
||||
type="password"
|
||||
on-focus="onFocus"
|
||||
auto-validate></paper-input>
|
||||
<paper-input id="password2"
|
||||
bind-value="{{password2}}"
|
||||
label="{{localize('repeat')}}"
|
||||
required
|
||||
type="password"
|
||||
on-focus="onFocus"
|
||||
auto-validate></paper-input>
|
||||
</div>
|
||||
<div class="card-actions">
|
||||
|
@ -153,6 +156,14 @@
|
|||
|
||||
</div>
|
||||
|
||||
<paper-dialog id="dlg" modal on-iron-overlay-closed="onCloseDlg">
|
||||
<h2>[[dlgTitle]]</h2>
|
||||
<p>[[dlgText]]</p>
|
||||
<div class="buttons">
|
||||
<paper-button dialog-confirm autofocus>Close</paper-button>
|
||||
</div>
|
||||
</paper-dialog>
|
||||
|
||||
<iron-ajax id="ajaxAuthCheck"
|
||||
handle-as="json"
|
||||
method="HEAD"
|
||||
|
@ -178,9 +189,6 @@
|
|||
],
|
||||
|
||||
properties: {
|
||||
app: {
|
||||
type: Object
|
||||
},
|
||||
basePath: {
|
||||
type: String,
|
||||
value: function () {
|
||||
|
@ -205,8 +213,8 @@
|
|||
code: {
|
||||
type: String
|
||||
},
|
||||
dlgTitle : {
|
||||
type:String
|
||||
dlgTitle: {
|
||||
type: String
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -214,12 +222,20 @@
|
|||
// do nothing
|
||||
},
|
||||
|
||||
onFocus: function (evt) {
|
||||
evt.target.$.input.select();
|
||||
},
|
||||
|
||||
onCloseDlg: function (evt) {
|
||||
this.$.username.inputElement.select();
|
||||
},
|
||||
|
||||
attached: function () {
|
||||
// this component has its own locales resources to load
|
||||
this.loadResources(this.resolveUrl("./locales.json"));
|
||||
|
||||
// default the language to english, if there is none given by the app
|
||||
if(!this.language) this.language = "en";
|
||||
if (!this.language) this.language = "en";
|
||||
},
|
||||
|
||||
reload: function () {
|
||||
|
@ -243,7 +259,9 @@
|
|||
sessionValidated: function () {
|
||||
console.log("Session validated.");
|
||||
Strolch.sessionVerified = true;
|
||||
this.app.sessionValid();
|
||||
this.fire('strolch-session-valid', {
|
||||
sessionVerified: true
|
||||
});
|
||||
},
|
||||
sessionInvalid: function () {
|
||||
console.log("Session invalid.");
|
||||
|
@ -263,7 +281,7 @@
|
|||
dlgText = data.detail.error;
|
||||
}
|
||||
|
||||
this.app.showError(this.dlgTitle, dlgText);
|
||||
this.showError(this.dlgTitle, dlgText);
|
||||
},
|
||||
|
||||
logout: function () {
|
||||
|
@ -378,7 +396,7 @@
|
|||
this.$.password2.invalid = true;
|
||||
var dlgTitle = "Reset failed";
|
||||
var dlgText = 'Passwords do not match.';
|
||||
this.app.showError(dlgTitle, dlgText);
|
||||
this.showError(dlgTitle, dlgText);
|
||||
}
|
||||
|
||||
console.log('Doing reset...');
|
||||
|
@ -396,6 +414,13 @@
|
|||
'password': btoa(this.password1)
|
||||
};
|
||||
this.$.ajaxAuth.generateRequest();
|
||||
},
|
||||
|
||||
showError: function (title, text) {
|
||||
this.dlgTitle = title;
|
||||
this.dlgText = text;
|
||||
console.log('ERROR: ' + this.dlgTitle + ': ' + this.dlgText);
|
||||
this.$.dlg.open();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue