If you're planning on running these on your server don't forget to:
php composer.phar install
and initialize the environment
php init
The tutorial is located here Neat Tutorials
Home Page: http://blog.neattutorials.com/angularjs-and-yii2-part-2-authentication/
License: Other
If you're planning on running these on your server don't forget to:
php composer.phar install
and initialize the environment
php init
The tutorial is located here Neat Tutorials
How to make that user is not thrown out of the session after a while?
Hi,
I just cloned your repository,
Yii main directory vendor always missing,
also angularjs files missing too.
Can you see into this issue please.
Hi,
Can anybody help me ... I am getting 401 error. The error response is:
{"name":"Unauthorized","message":"You are requesting with an invalid credential.","code":0,"status":401,"type":"yii\web\UnauthorizedHttpException"}
I am using same code and after login it returning me access_token but after login it redirect me to login with 401 Error
I debug with code step by step and finally i got this:
In "yii\filters\auth\HttpBearerAuth" class "authenticate" method is returning me null ... I print value for "$request->getHeaders()->get('Authorization')" and its return me blank.
can anybody know this why?
Thanks
I login success but can not get user info in actionDashboard()
'username' => Yii::$app->user->identity->username,
'access_token' => Yii::$app->user->identity->getAuthKey(),
and error: the server responded with a status of 403 (Forbidden)
I follow the tutorial and when i am going to login without filling credentials it returns error message in array(exception 'yii\base\InvalidRouteException' with message 'Unable to resolve the request "contact") . It's fine, but it do not show me message below the text field.
Below is my code:
Controller.js
controllers.controller('LoginController', ['$scope', '$http', '$window', '$location',
function($scope, $http, $window, $location) {
$scope.login = function () {
$scope.submitted = true;
$scope.error = {};
$http.post('api/login', $scope.userModel).success(
function (data) {
$window.sessionStorage.access_token = data.access_token;
$location.path('/dashboard').replace();
}).error(
function (data) {
angular.forEach(data, function (error) {
$scope.error[error.field] = error.message;
});
}
);
};
}
]);
ApiController.php
public function actionLogin()
{
$model = new LoginForm();
if ($model->load(Yii::$app->getRequest()->getBodyParams(), '') && $model->login()) {
return ['access_token' => Yii::$app->user->identity->getAuthKey()];
} else {
$model->validate();
return $model;
}
}
login.html
<form ng-submit="login()" name="loginForm" id="login-form" method="post" role="form" >
<div ng-class="{ 'has-success': !error['username'] && submitted,
'has-error': error['username'] && submitted }"
class="form-group field-loginform-username required">
<label class="control-label" for="loginform-username">Username(demo)</label>
<input ng-model="userModel.username" type="text" id="loginform-username" class="form-control">
<p class="help-block help-block-error">{{ error['username'] }}</p>
</div>
<div ng-class="{ 'has-success': !error['password'] && submitted,
'has-error': error['password'] && submitted }"
class="form-group field-loginform-password required">
<label class="control-label" for="loginform-password">Password(demo)</label>
<input ng-model="userModel.password" type="password" id="loginform-password" class="form-control">
<p class="help-block help-block-error">{{ error['password'] }}</p>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary" name="login-button">Login</button>
</div>
</form>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.