authentication


emberjs component form action


I'm trying to authenticate against DRF token.
I've successfully been able to login using an auth app I have created.
I thought I'd be slick and make the login form a component.
Since making it a component however, I'm not able to login and I get an Assertion failure.
My templates/components/auth-login.hbs template looks like so ...
<form class='navbar-form navbar-right' {{action 'authenticate' on='submit'}}>
<div class="form-group">
{{input id='identification' placeholder='Username' type='text' class='form-control' value=identification}}
{{input id='password' placeholder='Password' type='password' class='form-control' value=password}}
</div>
<button type="submit">Login</button>
</form>
I also have app/controllers/auth-login.js
import Ember from 'ember';
export default Ember.Controller.extend({
session: Ember.inject.service(),
actions: {
authenticate: function() {
var credentials = this.getProperties('identification', 'password'),
authenticator = 'authenticator:jwt';
this.get('session').authenticate(authenticator, credentials).catch((reason) => {
this.set('errorMessage', reason.error || reason);
});
}
}
});
It works as an app but not as a component.
If I blank the template, and use the auth route/app instead, it works peachy.
Option 1. You need to define action authenticate in actions hash of auth-login component.
Option 2. You can keep identification, password properties and authenticate action in controller. and include the auth-component like below,
app/templates/application.hbs
{{auth-component identification=identification password=password authenticate="authenticate" }}
app/components/auth-component.js
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
authenticate() {
this.sendAction('authenticate'); //this will call corresonding controller authenticate method through bubbling.
}
}
});
app/controllers/application.js
import Ember from 'ember';
export default Ember.Controller.extend({
session: Ember.inject.service(),
actions: {
authenticate: function() {
var credentials = this.getProperties('identification', 'password'),
authenticator = 'authenticator:jwt';
this.get('session').authenticate(authenticator, credentials).catch((reason) => {
this.set('errorMessage', reason.error || reason);
});
}
}
});

Related Links

ASP Core Add Custom Claim to Auth Token
Aspnet.Security.OpenIdConnect.Server Error on ASP.net Core 1.0 RTM
Azure Mobile App Service Authentication
LoggedInOutlet angular2 authentication - Router v3.0.0-alpha8 - Where is ComponentInstruction?
failing to authenticate with spring security
Windows app captcha and web api authenction token
CakePHP 3 : Trying to get property of non-object
What is the proper way to login a user in ReactJS for a Single-Page Application? [closed]
SHA1 to SHA2 transition - SHA1 depreciation plan
Yii2 user registration
Simplify application access for SharePoint 2013 with AD FS 3.0 using a reverse proxy
How to authenticate user via OIM API?
Office Add-ins : Windows Authentication (Get User Name who Logged into Machine)
User Authentication. No error messege. Laravel
Kerberos Double Hop Delegation with ASP.NET Core (4.5.2)
JHipster OAuth can't get token - 405 error

Categories

HOME
sorting
access-vba
windows-phone-8
racket
rx-java2
hp-uft
glsles
rspec
mvvm
semaphore
iperf
symfony-3.1
ios7
matlab-figure
gitlab-pages
azure-keyvault
multi-tenant
asp.net-core-1.1
gif
phonegap-plugins
pardot
android-mediaplayer
code-folding
beagleboneblack
extendscript
cgroups
symfony-2.7
swift-playground
opentok
graph-visualization
ram
spss-modeler
predicate
imagemagick-convert
entity-framework-5
alarms
intel-edison
azure-sdk-.net
truncate
excel-2011
args
cortana-intelligence
daterangepicker
scim
mobileiron
certutil
j2v8
jquery-post
surface
sql-merge
openvas
unificationengine
soundmanager2
dymo
array-algorithms
open-sesame
slimdx
dev-to-production
google-directory-api
where-clause
actionbarsherlock
posthoc
google-reporting-api
dfs
ime
scalastyle
curves
shimmercat
storio
ruby-1.9.3
pushsharp
virus-scanning
handwriting-recognition
andromda
subtraction
zohobooks
mixcloud
quora
keyboard-hook
sieve-language
emit
android-intentservice
maintainability
esent
hoist
openmq
phpt
microsoft-bits
activeresource
convex
joosy
jrubyonrails
python-nose
vmc
wadl
sp-send-dbmail
string-literals
countdownlatch
browser-testing
radtreeview
papervision3d
hdrimages

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App