Frage

I am using securesocial it works fine but now every time I change some scala code I have to login again. Is there a possibility to fake a user in the session when in development mode, so I don't have to login so often?

Thanks,

Joris Wijlens

War es hilfreich?

Lösung

That happens because in DEV mode Play restarts the app when you change your code. So, the data in the sample user service is lost.

Andere Tipps

SecureSocial by default uses the default Play cache for storing authenticators (that match the cookies to the logged in user). The default play cache is EHCache and it's configured using the ehcache.xml that you can find in the jars. The default configuration is strictly in memory which means that when the app restarts, it loses all the values. Fortunately, it's pretty easy to overwrite the EHCache configuration to write to the disk.

Copy the ehcache.xml in the jars to your configuration directory. Add <diskStore path="java.io.tmpdir"/> and change diskPersistent to true

So mine looks like this:

<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../config/ehcache.xsd" updateCheck="false">
<diskStore path="java.io.tmpdir"/>
<defaultCache
        maxElementsInMemory="10000"
        eternal="false"
        timeToIdleSeconds="120"
        timeToLiveSeconds="120"
        overflowToDisk="false"
        maxElementsOnDisk="10000000"
        diskPersistent="true"
        diskExpiryThreadIntervalSeconds="120"
        memoryStoreEvictionPolicy="LRU"
        />
</ehcache>

If you're interested learning how to configure the rest of it, there is some documentation in the ehcache-failsafe.xml file that's also in the Play jars.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top