简体   繁体   English

如何验证注销并重定向到登录页面

[英]How to verify signout and redirect to sign in page

In order to signout from my webapp, I need to call a json to signout (clear all cookies) 为了从我的Web应用程序注销,我需要调用json进行注销(清除所有cookie)

logout:->
    $.get('/signout.json')

However, I am unsure how I can refresh the page + redirect the web page to the address i want eg /#!/signin? 但是,我不确定如何刷新页面+将网页重定向到我想要的地址,例如/#!/ signin? after the signout is successful. 登出成功后。

if you want to solve it in javascript just use window.location = "yourlinkhere" 如果您想在javascript中解决它,只需使用window.location = "yourlinkhere"

I use the same sort of thing to determine if I have to show a push notification. 我使用相同的方法来确定是否必须显示推送通知。 I also use asp.net and vb.net so not sure if it will help you but you will get a basic idea of what to do :) 我也使用asp.net和vb.net,所以不确定它是否对您有帮助,但是您会基本了解该怎么做:)

//admin is the controller the second is the function.
 $.post("/admin/UpdateBrainBattle/

That function will return a json. 该函数将返回一个json。 in this case its about submitting a form. 在这种情况下,它是关于提交表格的。 so you check if the form is valid or not. 所以您检查表格是否有效。 in the end it shows this: 最后显示如下:

 Return Json(New With {.status = "error"})

or when its good its with .status = "ok" Then I get the json back on my page. 或当.status = "ok"很好时,我将json返回我的页面。 This is the whole function(including the post function) 这是整个功能(包括发布功能)

$.post("/admin/UpdateBrainBattle/" + sessionId, { questionId: key, startTimeField: startTimeField, startDateField: startDateField },
                   function(data) {
                        if (data.status == 'ok'){
                         parentLi.find('li.onedit').hide();
                         parentLi.find('li.onview').show();
                         parentLi.find('div.dateTimeBlock div.view').html(data.value).show();
                         parentLi.find('div.dateTimeBlock div.edit').hide();
                         $('.errorBlockSummary').hide();
                         }
                         else
                         {
                            parentLi.find('span.errorBlock').show();
                            $('.errorBlockSummary').show();
                         }
                   });

This way you can tell your page, if everything was succesful go to this page, otherwise take this action. 这样,您可以告诉您的页面,如果一切成功,请转至此页面,否则请执行此操作。 Hope this helped you a bit on your way :) 希望这对您有所帮助:)

Edit: noted you used a $.get instead, it can work exactly the same way as long as the function you call to has a return value you should be fine. 编辑:注意,您改用$ .get,只要调用的函数具有返回值就可以了,它可以完全相同地工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM