bool Cws_accountEx::onMyAccount(IEspContext &context, IEspMyAccountRequest &req, IEspMyAccountResponse &resp) { try { ISecUser* user = context.queryUser(); if(user != NULL) { CDateTime dt; user->getPasswordExpiration(dt); StringBuffer sb; if (dt.isNull()) sb.append("Never"); else { dt.getString(sb); sb.replace('T', (char)0);//chop off timestring } resp.setPasswordExpiration(sb.str()); resp.setPasswordDaysRemaining(user->getPasswordDaysRemaining()); resp.setFirstName(user->getFirstName()); resp.setLastName(user->getLastName()); resp.setUsername(user->getName()); } } catch(IException* e) { FORWARDEXCEPTION(context, e, ECLWATCH_INTERNAL_ERROR); } return true; }
const StringBuffer &CEspApplicationPort::getAppFrameHtml(time_t &modified, const char *inner, StringBuffer &html, IEspContext* ctx) { if (!xslp) throw MakeStringException(0,"Error - CEspApplicationPort XSLT processor not initialized"); bool embedded_url=(inner&&*inner); StringBuffer params; bool needRefresh = true; if (!getUrlParams(ctx->queryRequestParameters(), params)) { if (params.length()==0) needRefresh = false; if (ctx->getClientVersion()>0) { params.appendf("%cver_=%g", params.length()?'&':'?', ctx->getClientVersion()); needRefresh = true; } } if (needRefresh || embedded_url || !appFrameHtml.length()) { int passwordDaysRemaining = scPasswordExpired;//-1 means dont display change password screen #ifdef _USE_OPENLDAP ISecUser* user = ctx->queryUser(); ISecManager* secmgr = ctx->querySecManager(); if(user && secmgr) { passwordDaysRemaining = user->getPasswordDaysRemaining();//-1 if expired, -2 if never expires int passwordExpirationDays = (int)secmgr->getPasswordExpirationWarningDays(); if (passwordDaysRemaining == scPasswordNeverExpires || passwordDaysRemaining > passwordExpirationDays) passwordDaysRemaining = scPasswordExpired; } #endif StringBuffer xml; StringBuffer encoded_inner; if(inner && *inner) encodeXML(inner, encoded_inner); // replace & with &s; params.replaceString("&","&"); xml.appendf("<EspApplicationFrame title=\"%s\" navWidth=\"%d\" navResize=\"%d\" navScroll=\"%d\" inner=\"%s\" params=\"%s\" passwordDays=\"%d\"/>", getESPContainer()->getFrameTitle(), navWidth, navResize, navScroll, (inner&&*inner) ? encoded_inner.str() : "?main", params.str(), passwordDaysRemaining); Owned<IXslTransform> xform = xslp->createXslTransform(); xform->loadXslFromFile(StringBuffer(getCFD()).append("./xslt/appframe.xsl").str()); xform->setXmlSource(xml.str(), xml.length()+1); xform->transform( (needRefresh || embedded_url) ? html.clear() : appFrameHtml.clear()); } if (!needRefresh && !embedded_url) html.clear().append(appFrameHtml.str()); static time_t startup_time = time(NULL); modified = startup_time; return html; }