{"action":"created","issue":{"url":"https://api.github.com/repos/jhipster/generator-jhipster/issues/1800","labels_url":"https://api.github.com/repos/jhipster/generator-jhipster/issues/1800/labels{/name}","comments_url":"https://api.github.com/repos/jhipster/generator-jhipster/issues/1800/comments","events_url":"https://api.github.com/repos/jhipster/generator-jhipster/issues/1800/events","html_url":"https://github.com/jhipster/generator-jhipster/issues/1800","id":98566255,"number":1800,"title":"Empty alerts on errors 403","user":{"login":"gmarziou","id":361007,"avatar_url":"https://avatars.githubusercontent.com/u/361007?v=3","gravatar_id":"","url":"https://api.github.com/users/gmarziou","html_url":"https://github.com/gmarziou","followers_url":"https://api.github.com/users/gmarziou/followers","following_url":"https://api.github.com/users/gmarziou/following{/other_user}","gists_url":"https://api.github.com/users/gmarziou/gists{/gist_id}","starred_url":"https://api.github.com/users/gmarziou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gmarziou/subscriptions","organizations_url":"https://api.github.com/users/gmarziou/orgs","repos_url":"https://api.github.com/users/gmarziou/repos","events_url":"https://api.github.com/users/gmarziou/events{/privacy}","received_events_url":"https://api.github.com/users/gmarziou/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/jhipster/generator-jhipster/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-08-01T22:50:54Z","updated_at":"2015-08-02T02:25:35Z","closed_at":null,"body":"Hi team,\r\n\r\nI had a problem of invalid CSRF cookie, in login screen this resulted in 2 requests in error and 2 empty alerts being displayed. My app was configured with \"enableTranslation\": true.\r\n\r\nPOST /api/authentication error 403\r\n{\"timestamp\":1438467827536,\"status\":403,\"error\":\"Forbidden\",\"message\":\"Invalid CSRF Token 'null' was found on the request parameter '_csrf' or header 'X-CSRF-TOKEN'.\",\"path\":\"/api/authentication\"}\r\n\r\nPOST /api/logout error 403\r\n{\"timestamp\":1438467827571,\"status\":403,\"error\":\"Forbidden\",\"message\":\"Invalid CSRF Token 'null' was found on the request parameter '_csrf' or header 'X-CSRF-TOKEN'.\",\"path\":\"/api/logout\"}\r\n\r\nThe problem is in alert.directive.js :\r\n\r\n~~~\r\n\tvar addErrorAlert = function (message, key, data) {\r\n\t\tAlertService.error(key, data);\r\n\t}\r\n~~~\r\n\r\nWhen entering this function, the parameters were:\r\n\r\n~~~\r\n   message = \"Invalid CSRF Token 'null' was found on the request parameter '_csrf' or header 'X-CSRF-TOKEN'.\"\r\n   key = undefined\r\n   data = undefined\r\n~~~\r\n\r\nSo either, we should display the message or we should not display the alert.\r\n\r\n401 and 403 are probably special cases that may require special processing, as the error is correctly handled by the LoginController which displays an error 'Authentication failed...'. \r\nSo here I think no alert should be displayed, but maybe it should be logged."},"comment":{"url":"https://api.github.com/repos/jhipster/generator-jhipster/issues/comments/126979347","html_url":"https://github.com/jhipster/generator-jhipster/issues/1800#issuecomment-126979347","issue_url":"https://api.github.com/repos/jhipster/generator-jhipster/issues/1800","id":126979347,"user":{"login":"deepu105","id":1107223,"avatar_url":"https://avatars.githubusercontent.com/u/1107223?v=3","gravatar_id":"","url":"https://api.github.com/users/deepu105","html_url":"https://github.com/deepu105","followers_url":"https://api.github.com/users/deepu105/followers","following_url":"https://api.github.com/users/deepu105/following{/other_user}","gists_url":"https://api.github.com/users/deepu105/gists{/gist_id}","starred_url":"https://api.github.com/users/deepu105/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deepu105/subscriptions","organizations_url":"https://api.github.com/users/deepu105/orgs","repos_url":"https://api.github.com/users/deepu105/repos","events_url":"https://api.github.com/users/deepu105/events{/privacy}","received_events_url":"https://api.github.com/users/deepu105/received_events","type":"User","site_admin":false},"created_at":"2015-08-02T02:25:35Z","updated_at":"2015-08-02T02:25:35Z","body":"Oh yes, i guess i was sending the message as fallback for no translation\nscenario, but i guess we should put a null check and overwite the message\nif key is null, ill do a PR today\n\nOn Sun, 2 Aug 2015 6:51 am Gaël Marziou <notifications@github.com> wrote:\n\n> Hi team,\n>\n> I had a problem of invalid CSRF cookie, in login screen this resulted in 2\n> requests in error and 2 empty alerts being displayed. My app was configured\n> with \"enableTranslation\": true.\n>\n> POST /api/authentication error 403\n> {\"timestamp\":1438467827536,\"status\":403,\"error\":\"Forbidden\",\"message\":\"Invalid\n> CSRF Token 'null' was found on the request parameter '_csrf' or header\n> 'X-CSRF-TOKEN'.\",\"path\":\"/api/authentication\"}\n>\n> POST /api/logout error 403\n> {\"timestamp\":1438467827571,\"status\":403,\"error\":\"Forbidden\",\"message\":\"Invalid\n> CSRF Token 'null' was found on the request parameter '_csrf' or header\n> 'X-CSRF-TOKEN'.\",\"path\":\"/api/logout\"}\n>\n> The problem is in alert.directive.js :\n>\n>     var addErrorAlert = function (message, key, data) {\n>         AlertService.error(key, data);\n>     }\n>\n> When entering this function, the params were:\n>\n>    message = \"Invalid CSRF Token 'null' was found on the request parameter '_csrf' or header 'X-CSRF-TOKEN'.\"\n>    key = undefined\n>    data = undefined\n>\n> So either, we should display the message or we should not display the\n> alert.\n> 401 and 403 are probably special cases that may require special\n> processing, as the error is correctly handled by the LoginController which\n> displays an error 'Authentication failure'.\n>\n> —\n> Reply to this email directly or view it on GitHub\n> <https://github.com/jhipster/generator-jhipster/issues/1800>.\n>\n"}}