From 853b292809a4ae2cf9bc057fc5e0faac33cc6d98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=B0=BD=EA=B7=BC?= Date: Mon, 6 Oct 2014 17:49:54 +0900 Subject: [PATCH] Fix invalid message when unauthorized user request to join as member of a private project. Reason: Basically, unauthorized user are denied access to private project. But, if unauthorized user access to private project page for any reason, and request to join as member of this project, then this user get to see the 'Server Error' flash message. Solution: * When unauthorized user request to join as member of a private project, the flash message is changed correct forbidden message. --- conf/messages | 4 +++ conf/messages.ko | 4 +++ .../service/yobi.project.Global.js | 25 +++++++++++++++++-- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/conf/messages b/conf/messages index 74364a457..87aef6124 100644 --- a/conf/messages +++ b/conf/messages @@ -836,6 +836,10 @@ user.deleted = Deleted user account user.email = Email address user.email.duplicate = Email address already exists user.email.new = New E-mail address +user.enroll.failed = Failed to Sign-up. Server error may have occurred or the request may be invalid. +user.enroll.failed.client = Failed to Sign-up. The request is invalid.\nPlease ask site admin. +user.enroll.failed.network = Failed to Sign-up because network trouble.\nPlease ask site admin. +user.enroll.failed.server = Failed to Sign-up because server error has occurred.\nPlease ask site admin. user.isAlreadySignupUser = Already signed up? user.isLocked = Is the user account locked out? user.locked = This user account is locked diff --git a/conf/messages.ko b/conf/messages.ko index 7a98282af..fae84c31c 100644 --- a/conf/messages.ko +++ b/conf/messages.ko @@ -837,6 +837,10 @@ user.deleted = 삭제된 사용자 계정입니다. user.email = 이메일 user.email.duplicate = 이미 존재하는 이메일입니다. user.email.new = 새 이메일 주소 +user.enroll.failed = 멤버 등록 요청에 실패하였습니다. 서버에 문제가 있거나 올바른 요청이 아닐 수 있습니다. +user.enroll.failed.client = 멤버 등록 요청에 실패하였습니다. 올바른 요청이 아닙니다.\n관리자에게 문의해주세요. +user.enroll.failed.network = 네트워크 문제로 인해 멤버 등록 요청에 실패하였습니다.\n관리자에게 문의해주세요. +user.enroll.failed.server = 서버의 문제로 인해 멤버 등록 요청에 실패하였습니다.\n관리자에게 문의해주세요. user.isAlreadySignupUser = 이미 가입하셨나요? user.isLocked = 잠김여부 user.locked = 잠긴 사용자 계정입니다. diff --git a/public/javascripts/service/yobi.project.Global.js b/public/javascripts/service/yobi.project.Global.js index 35554a7d8..dacef5e77 100644 --- a/public/javascripts/service/yobi.project.Global.js +++ b/public/javascripts/service/yobi.project.Global.js @@ -28,6 +28,10 @@ var htVar = {}; var htElement = {}; + var clientErrorStatus = /^4[0-9][0-9]$/ + var serverErrorStatus = /^5[0-9][0-9]$/ + var networkErrorStatus = 0; + /** * initialize */ @@ -99,8 +103,25 @@ "success": function(){ document.location.reload(); }, - "error": function(){ - $yobi.notify("Server Error"); + "error": function(oXHR){ + if(oXHR.readyState == networkErrorStatus){ + $yobi.notify(Messages("user.enroll.failed.network"), 3000); + }else{ + switch(true){ + case oXHR.status == 403: + $yobi.notify(Messages("error.forbidden"), 3000); + break; + case clientErrorStatus.test(oXHR.status): + $yobi.notify(Messages("user.enroll.failed.client"), 3000); + break; + case serverErrorStatus.test(oXHR.status): + $yobi.notify(Messages("user.enroll.failed.server"), 3000); + break; + default: + $yobi.notify(Messages("user.enroll.failed"), 3000); + break; + } + } } })