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.Net MVC 4's SimpleMembership InitializeSimpleMembership not being called
Powershell BitsTransfer https basic authentication syntax
Using LDAP/AD to control access to a program - what is the account password?
jenkins LDAP authentication - deny
User Auth in EventSourcing applications
JAAS: Make application use Tomcat authentication settings
MVC4, UnitOfWork + DI, and SimpleAuthentication .. how to decouple?
ASP.Net MVC 4 Simple Membership specify Schema
openldap fortress vs Apache Shiro
Sitecore - Prevent access to a page, but still show it in the navigation
AOL reader authentication
sending encrypted password to LDAP server(Active Directory 2008)
Kohana 3.3 expanding the Auth module
Live Connect as Azure ACS Identity Provider
why qtnetworkaccessmanager don't go to authenticationRequired
Convert cookie string to a Cookie object in C# or Java

Categories

HOME
calculator
cassandra-2.0
spring-integration
time
duplicates
eigen
matlab-figure
webhooks
unmanaged
phonegap-plugins
evolutionary-algorithm
telerik-open-access
saxparser
clock
transformer
binary-search-tree
filenotfoundexception
escaping
zipkin
direct2d
chez-scheme
mumps
relationship
pgbouncer
polynomial-math
specman
keypress
alter-table
libsodium
this
ios10-today-widget
apt
todoist
gxt
stocktwits
jaas
information-extraction
columnstore
globalplatform
osx-server
antlrworks
rake
string-comparison
instamojo
surface
ruta
rdd
variable-assignment
winnovative
papi
firebase-console
nxp-microcontroller
javaparser
java-api
vimeo-android
opencart-module
dev-to-production
cfengine
maxrequestlength
homogenous-transformation
sql-server-migration-assi
flask-migrate
storio
fiware-cosmos
sql-server-2008r2-express
loggly
named
vanity-url
rendr
wso2bps
remotewebdriver
jsduck
convention-over-configur
luabridge
emit
dynamic-arrays
sonarqube-4.0
sourcesafe-6.0
learn-ruby-on-rails
onitemclicklistener
browser-automation
imperative-programming
equations
readdirectorychangesw
command-query-separation
cocoaasyncsocket
genson
tss
abortbroadcast
continuum
p4v
integer-division
paypal-buttons
activeresource
mipmaps
conjunctive-normal-form
packed
bitkeeper
google-gauges
string-utils
word-diff
morphological-analysis

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App