I don't think that a member service exists for AngularJS - Someone correct me if I'm wrong - However I'm thinking you might be able to create one yourself by using the Umbraco API and create your own member service perhaps?
In the below example I created an oauth service that can be used for login and logut operation in the app. It internally depends on custom currentUser and formEncode service and angular built-in $http service. You can learn more about this angularjs service here.
angular.module("app")
.config(function ($provide) {
$provide.provider("oauth", function () {
var url = "/token";
this.setUrl = function (newUrl) {
url = newUrl;
};
this.$get = function ($http, formEncode, currentUser) {
var processToken = function (username) {
return function (response) {
currentUser.profile.username = username;
currentUser.profile.token = response.data.access_token;
currentUser.save();
$http.get(`api/IdentityEmployee/${username}`).then(function (res) {
currentUser.profile.userInfo = res.data;
currentUser.save();
});
return username;
}
};
var login = function (username, password) {
var configuration = {
headers: {
"Content-Type": "application/x-www-form-urlencoded"
}
};
var data = formEncode({
username: username,
password: password,
grant_type: "password"
});
return $http.post(url, data, configuration).then(processToken(username));
};
var logout = function () {
currentUser.profile.username = "";
currentUser.profile.token = "";
currentUser.remove();
};
return {
login: login,
logout: logout
};
}
});
});
angular.module("app").config(["oauthProvider", function(oauthProvider) {
oauthProvider.setUrl('/another-token-url');
}]);
Member login in single page app using AngularJS
I am developing a single page app in Umbraco 7 using AngularJS. I need to login members to the site, but I can't find a good way to do this?
Have someone experience and would like to share their knowledge with me?
Hi Dennis
I don't think that a member service exists for AngularJS - Someone correct me if I'm wrong - However I'm thinking you might be able to create one yourself by using the Umbraco API and create your own member service perhaps?
You can learn more about the Umbraco API here https://our.umbraco.org/documentation/Reference/Management-v6/
Hope this helps a bit.
/Jan
Yes I thought so. Oki I develop my own. I found this fine article on how to develop a login mechanism in AngularJS:
http://brewhouse.io/blog/2014/12/09/authentication-made-simple-in-single-page-angularjs-applications.html
In the below example I created an oauth service that can be used for login and logut operation in the app. It internally depends on custom currentUser and formEncode service and angular built-in $http service. You can learn more about this angularjs service here.
is working on a reply...