Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Oblomingo 2 posts 72 karma points
    Mar 13, 2017 @ 07:05
    Oblomingo
    0

    Backoffice user login/logout event in plugin frontend

    Hello, a little help for a newbie with a Umbraco plugin development. I hope some one out there can help me,

    I'm developing plugin frontend with angularjs. My application logic depends on backend user. If user loged in I must show one form, if user loged out I must show other form.

    I can get current user this way:

    Asp.Net MVC controller action:

    [HttpGet]
    public IHttpActionResult GetCurrentUser()
    {
        var userTicket = new HttpContextWrapper(HttpContext.Current).GetUmbracoAuthTicket();
        if (userTicket != null)
        {
            IUser currentUser = ApplicationContext.Services.UserService.GetByUsername(userTicket.Name);
            return Ok(new UserViewModel(currentUser));
        }
    
        return Ok();
    }
    

    In angular service can take user:

    function getCurrentUser() {
        var url = '/umbraco/api/UserApi/GetCurrentUser';
        return $http.get(url).then(handleSuccess, handleError('Error getting current user'));
    }
    

    Ok, I can get information about user, but I can't get an event when this user log out. I doesn't want to use polling in this case. Maybe there is a better soliution?

Please Sign in or register to post replies

Write your reply to:

Draft