I have a basic controller defined in C#, its only purpose is to return whoever the current user is.
namespace ProjectName.Controllers
{
public class UserController : ApiController
{
// GET api/user/
public string Get()
{
return User.Identity.Name;
}
}
}
I then have an ngResource defined to look at that controller
cript.factory('User', function ($resource) {
return $resource('/api/User')
});
finally I try to get that user in my Angular Controller
$scope.checkIfAuth = function () {
$scope.user = User.get();
console.log($scope.user);
if ($scope.user === '"DS//:lemieszr"') {
console.log("success");
}
};
The problem is $scope.user is a resource object that looks like this
Resource {$get: function, $save: function, $query: function, $remove: function, $delete: function}
0: """
1: "D"
2: "S"
3: "\"
4: "\"
5: "l"
6: "e"
7: "m"
8: "i"
9: "e"
10: "s"
11: "z"
12: "r"
13: """
__proto__: Resource
Is there anyway to just get the string containing my Username. User.query() only returns an empty array.