Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Fix guest user case in new login flow. Guest needs to have access to …
Browse files Browse the repository at this point in the history
…home dashboard to login. Fix no active repository case.
  • Loading branch information
cdujeu committed Sep 3, 2014
1 parent a555e81 commit 4739e95
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 179 deletions.
2 changes: 1 addition & 1 deletion core/src/core/classes/class.AuthService.php
Expand Up @@ -117,7 +117,7 @@ public static function getLoggedUser()
*/
public static function preLogUser($httpVars)
{
if(self::getLoggedUser() != null) return ;
if(self::getLoggedUser() != null && self::getLoggedUser()->getId() != "guest") return ;

$frontends = AJXP_PluginsService::getInstance()->getActivePluginsForType("authfront");
$index = 0;
Expand Down
3 changes: 3 additions & 0 deletions core/src/core/classes/class.ConfService.php
Expand Up @@ -1183,6 +1183,9 @@ public function loadRepositoryDriverInst()
}
$this->switchRootDirInst();
$crtRepository = $this->getRepositoryInst();
if($crtRepository == null){
throw new Exception("No active repository found for user!");
}
$accessType = $crtRepository->getAccessType();
$pServ = AJXP_PluginsService::getInstance();
$plugInstance = $pServ->getPluginByTypeName("access", $accessType);
Expand Down
8 changes: 6 additions & 2 deletions core/src/index.php
Expand Up @@ -97,7 +97,7 @@
AuthService::logUser(null, null);
// Check that current user can access current repository, try to switch otherwise.
$loggedUser = AuthService::getLoggedUser();
if ($loggedUser == null) {
if ($loggedUser == null || $loggedUser->getId() == "guest") {
// Try prelogging user if the session expired but the logging data is in fact still present
// For example, for basic_http auth.
AJXP_PluginsService::getInstance()->initActivePlugins();
Expand Down Expand Up @@ -139,7 +139,11 @@
// DRIVERS BELOW NEED IDENTIFICATION CHECK
if (!AuthService::usersEnabled() || ConfService::getCoreConf("ALLOW_GUEST_BROWSING", "auth") || AuthService::getLoggedUser()!=null) {
$confDriver = ConfService::getConfStorageImpl();
$Driver = ConfService::loadRepositoryDriver();
try{
$Driver = ConfService::loadRepositoryDriver();
}catch(Exception $e){
//AuthService::disconnect();
}
}
AJXP_PluginsService::getInstance()->initActivePlugins();
require_once(AJXP_BIN_FOLDER."/class.AJXP_Controller.php");
Expand Down
7 changes: 6 additions & 1 deletion core/src/plugins/access.ajxp_home/class.UserDashboardHome.js
Expand Up @@ -207,12 +207,17 @@ Class.create("UserDashboardHome", AjxpPane, {
switchToRepo(target.CURRENT_REPO_ID);
});

if(ajaxplorer.actionBar.getActionByName("logout")){
if(ajaxplorer.actionBar.getActionByName("logout") && ajaxplorer.user.id != "guest"){
oFormObject.down("#welcome").insert('<small>'+MessageHash["user_home.67"].replace("%logout", "<span id='disconnect_link'></span>").replace('%s', ajaxplorer.user.getPreference("USER_DISPLAY_NAME") || ajaxplorer.user.id)+'</small>');
oFormObject.down('#disconnect_link').update("<a>"+ajaxplorer.actionBar.getActionByName("logout").options.text.toLowerCase()+"</a>");
oFormObject.down('#disconnect_link').observe("click", function(e){
ajaxplorer.actionBar.fireAction("logout");
});
}else if(ajaxplorer.user.id == "guest" && ajaxplorer.actionBar.getActionByName("login")){
oFormObject.down("#welcome").insert("<small>You can <a id='disconnect_link'>login</a> if you are not guest.</small>");
oFormObject.down('#disconnect_link').observe("click", function(e){
ajaxplorer.actionBar.fireAction("login");
});
}

if(ajaxplorer.getPluginConfigs('access.ajxp_home').get("ENABLE_GETTING_STARTED")){
Expand Down
175 changes: 0 additions & 175 deletions core/src/plugins/core.auth/standard_auth_actions.xml
@@ -1,181 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<registry_contributions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:../core.ajaxplorer/ajxp_registry.xsd">
<actions>
<!--
<action name="login">
<gui text="163" title="168" src="encrypted.png" iconClass="icon-signin"
accessKey="" hasAccessKey="false">
<context selection="false" dir="" recycle="false"
actionBar="true" contextMenu="false" infoPanel="false"
actionBarGroup="user">
</context>
</gui>
<rightsContext noUser="false" userLogged="hidden" guestLogged="show" read="false" write="false" adminOnly=""></rightsContext>
<processing>
<clientCallback prepareModal="true"><![CDATA[
var loginRedirect = AJXP_LOGIN_REDIRECT;
if(loginRedirect){
document.location.href=loginRedirect;
}else{
modal.setCloseValidation(function(){
return (!!ajaxplorer && !!ajaxplorer.user && ajaxplorer.user.id == "guest")
});
modal.showDialogForm('Log In', ($('login_form')?'login_form':'login_form_dynamic'),
function(oForm){
$("generic_dialog_box").setStyle({
top:$("progressBox").getStyle('top'),
left:$("progressBox").getStyle('left')
});
var authConfs = ajaxplorer.getPluginConfigs("auth");
if(!authConfs) authConfs = $H();
if(!Modernizr.input.placeholder) oForm.addClassName('no_placeholder');
if(window.ajxpBootstrap.parameters.get('PRESET_LOGIN')){
oForm.addClassName('ajxp_preset_login');
oForm.down('input[name="userid"]').setValue(window.ajxpBootstrap.parameters.get('PRESET_LOGIN'));
}
if(window.ajxpBootstrap.parameters.get('PRESET_PASSWORD')){
oForm.addClassName('ajxp_preset_password');
oForm.down('input[name="password"]').setValue(window.ajxpBootstrap.parameters.get('PRESET_PASSWORD'));
}
if(window.ajxpBootstrap.parameters.get('PASSWORD_AUTH_ONLY')){
oForm.addClassName('ajxp_password_auth');
authConfs.set('SECURE_LOGIN_FORM', true);
authConfs.set('ENABLE_FORGOT_PASSWORD', false);
}
$("generic_dialog_box").down(".titleString").hide();
$("generic_dialog_box").down("#modalCloseBtn").hide();
$("generic_dialog_box").down(".dialogTitle").setAttribute("style", $("progressBox").down(".dialogTitle").getAttribute("style"));
if(!$("generic_dialog_box").down("#progressCustomMessage")){
if($("progressBox").down("#progressCustomMessage")) $("generic_dialog_box").down(".dialogContent").insert({top:$("progressBox").down("#progressCustomMessage").cloneNode(true)});
}
oForm.setStyle({display:'block'});
oForm.up(".dialogContent").setStyle({backgroundImage:'none', borderWidth:0});
ajaxplorer.loadSeedOrCaptcha(oForm.down('#login_seed'), oForm.down('img#captcha_image'), oForm.down('div.dialogLegend'), 'before');
if(Prototype.Browser.IE && !Modernizr.borderradius && !oForm.down('input[type="text"]').key_enter_attached){
oForm.select('input').invoke("observe", "keydown", function(event){
if(event.keyCode == Event.KEY_RETURN){
var el = Event.findElement(event);
if(el.hasClassName('dialogButton')){
el.click();
}else{
el.form.down('input.dialogButton').click();
}
}
});
oForm.down('input[type="text"]').key_enter_attached = true;
}
if(authConfs && authConfs.get("SECURE_LOGIN_FORM")){
try{
oForm.down('input[name="remember_me"]').up("div.SF_element").remove();
oForm.down('input[name="userid"]').setAttribute("autocomplete", "off");
oForm.down('input[name="password"]').setAttribute("autocomplete", "off");
oForm.setAttribute("autocomplete", "off");
}catch(e){}
}
if(authConfs && authConfs.get("ENABLE_FORGOT_PASSWORD") && !oForm.down('a.forgot-password-link')){
try{
oForm.down('input[name="password"]').up("div.SF_element").insert({after:'<div class="SF_element"><a href="#" class="forgot-password-link" ajxp_message_id="479">AJXP_MESSAGE[479]</a></div>'});
oForm.down('a.forgot-password-link').observe("click", function(e){
Event.stop(e);
ajaxplorer.actionBar.fireAction(authConfs.get("FORGOT_PASSWORD_ACTION"));
});
}catch(e){ if(console) console.log(e); }
}
modal.refreshDialogPosition();
},
function(){
var oForm = modal.getForm();
var connexion = new Connexion();
connexion.addParameter('get_action', 'login');
connexion.addParameter('userid', window.ajxpBootstrap.parameters.get('PRESET_LOGIN')?window.ajxpBootstrap.parameters.get('PRESET_LOGIN'):oForm.userid.value);
connexion.addParameter('login_seed', oForm.login_seed.value);
connexion.addParameter('remember_me', (oForm.remember_me && oForm.remember_me.checked?"true":"false"));
if(oForm.login_seed.value != '-1'){
connexion.addParameter('password', hex_md5(hex_md5(oForm.password.value)+oForm.login_seed.value));
}else{
connexion.addParameter('password', oForm.password.value);
}
if(oForm.captcha_code){
connexion.addParameter('captcha_code', oForm.captcha_code.value);
}
connexion.onComplete = function(transport){
var success = ajaxplorer.actionBar.parseXmlMessage(transport.responseXML);
if(transport.responseXML && XPathGetSingleNodeText(transport.responseXML.documentElement, "logging_result/@value") == "-4"){
ajaxplorer.loadSeedOrCaptcha(oForm.down('#login_seed'), oForm.down('img#captcha_image'), oForm.down('div.dialogLegend'), 'before');
}
if(success){
$("generic_dialog_box").down(".dialogTitle").writeAttribute("style", "");
oForm.up('.dialogContent').writeAttribute("style", "");
$("generic_dialog_box").select("#progressCustomMessage").invoke("remove");
}
};
connexion.setMethod('put');
connexion.sendAsync();
oForm.userid.value = '';
oForm.password.value = '';
return false;
}, function(){}, true);
}
]]></clientCallback>
<clientForm id="login_form_dynamic"><![CDATA[
<form id="login_form_dynamic" action="login" style="display:none;" box_width="320" box_padding="0" overlayStyle='{"backgroundColor":"white","opacity":10,"backgroundImage":"url(\"AJXP_THEME_FOLDER/images/grid_t.png\")"}'>
<input type="hidden" name="get_action" value="login">
<input type="hidden" name="login_seed" id="login_seed" value="">
<a style="float:right;font-size: 16px;" href="javascript:ajaxplorer.actionBar.fireAction('switch_language');" title="AJXP_MESSAGE[190]" alt="AJXP_MESSAGE[190]" class="icon-flag">&nbsp;</a>
<div class="dialogLegend" style="margin-bottom: 3px;margin-top: 4px;" ajxp_message_id="180">AJXP_MESSAGE[180]</div>
<div style="width:100%;">
<div class="SF_element">
<div class="SF_label"><ajxp:message ajxp_message_id="181">AJXP_MESSAGE[181]</ajxp:message></div>
<div class="SF_input"><input type="text" name="userid" style="width: 100px; padding:0px;" class="dialogFocus" placeholder="AJXP_MESSAGE[181]"></div>
</div>
<div class="SF_element">
<div class="SF_label"><ajxp:message ajxp_message_id="182">AJXP_MESSAGE[182]</ajxp:message></div>
<div class="SF_input"><input type="password" name="password" style="width: 100px; padding:0px;" placeholder="AJXP_MESSAGE[182]"></div>
</div>
<div class="SF_element">
<input type="checkbox" class="radio" name="remember_me" style="border: none; width:20px !important;"/><ajxp:message ajxp_message_id="261">AJXP_MESSAGE[261]</ajxp:message>
</div>
</div>
</form>
]]></clientForm>
<serverCallback methodName="switchAction"></serverCallback>
</processing>
</action>
<action name="logout" expireDefault="true">
<gui text="164" title="169" src="decrypted.png" iconClass="icon-signout"
accessKey="" hasAccessKey="false">
<context selection="false" dir="" recycle="false"
contextMenu="false" actionBar="true" actionBarGroup="minisite" ajxpWidgets="UserWidget::logging_string">
</context>
</gui>
<rightsContext noUser="false" userLogged="only" guestLogged="hidden" read="false" write="false" adminOnly=""></rightsContext>
<processing>
<clientCallback prepareModal="false"><![CDATA[
clearRememberData();
var connexion = new Connexion();
connexion.addParameter('get_action', 'logout');
connexion.onComplete = function(transport){
ajaxplorer.actionBar.parseXmlMessage(transport.responseXML);
};
connexion.sendAsync();
]]></clientCallback>
<serverCallback methodName="switchAction"></serverCallback>
</processing>
</action>
<action name="get_seed">
<processing>
<serverCallback methodName="switchAction"/>
</processing>
</action>
<action name="get_captcha">
<processing>
<serverCallback methodName="switchAction"/>
</processing>
</action>
-->
<action name="get_secure_token">
<processing>
<serverCallback methodName="switchAction"/>
Expand Down

0 comments on commit 4739e95

Please sign in to comment.