Closed Jessdwilson closed 7 years ago
@Jessdwilson was a decision reached here about how they would accomplish this? I seem to remember Dave B. saying they would get back to us about how best to implement. cc: @davekellam
From Dave B.
Yes, that bit of color and name customization (assuming that authorizer can pass the required info) would appear when a user was logged in. This would customize according to school affiliation and serve as a way for people to understand that they are logged in already.
JavaScript/jQuery can read info from a cookie. The address webauth.claremont.edu
stores a cas_college
cookie, with the content being the school's subdomain, i.e. cuc.claremont.edu
. We should be able to read that cookie and adjust the colour accordingly. We can't do a whole lot beyond that.
@davekellam how do we call on that web address to get the cookie?
There's a js-cookie plugin/api for javascript that we could use. It might be overkill, as we probably don't need to set any cookies, so the relevant read bits could be pulled out.
So, I believe we'd do something like Cookies.get('cas_college');
to grab the cookie data, and then get the school's subdomain from the cookie content. Then use that info to apply the appropriate styles.
@davekellam, if we're not going to be providing a select box to change the school, we should probably just populate the data-school
attribute (on the root <html>
element) with PHP.
What do you think?
Also, I logged in with CAS to libraryweb.wpengine.com and ran document.cookie
in the browser console. This will give you a list of cookies for a site. Here's the only cookie I could find that referenced "webauth" and a school name, which happended to be Claremont Mckenna.
PHPSESSID=ST-251013-M6na4QfKnmqsgHQFCCTw-webauthclaremontmckennaedu
Didn't see a cookie with a cas_college
key
Right, I forgot that cookies are limited to same-origin policy, so we can't use it at the moment. If the site is on the same domain (claremont.edu), I imagine we can read the CAS cookie. In the interim we could set a default cookie of our own to use and/or set it with the switcher. We could leave out the switcher and offer some sort of site-options page that sets the cookie too.
The problem I see with setting the school via PHP is caching. WPE serves up cached pages to non-logged in users. So, setting it via php is likely to create unexpected behaviour. I could be wrong about this.
strip of color per campus color