summaryrefslogtreecommitdiff
path: root/resources/mediawiki/mediawiki.user.js
diff options
context:
space:
mode:
Diffstat (limited to 'resources/mediawiki/mediawiki.user.js')
-rw-r--r--resources/mediawiki/mediawiki.user.js25
1 files changed, 22 insertions, 3 deletions
diff --git a/resources/mediawiki/mediawiki.user.js b/resources/mediawiki/mediawiki.user.js
index e64d2e84..e0329597 100644
--- a/resources/mediawiki/mediawiki.user.js
+++ b/resources/mediawiki/mediawiki.user.js
@@ -61,7 +61,7 @@
*
* @return String: Random set of 32 alpha-numeric characters
*/
- function generateId() {
+ this.generateRandomSessionId = function () {
var i, r,
id = '',
seed = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
@@ -70,7 +70,7 @@
id += seed.substring( r, r + 1 );
}
return id;
- }
+ };
/**
* Gets the current user's name.
@@ -89,6 +89,25 @@
};
/**
+ * Get date user registered, if available.
+ *
+ * @return {Date|false|null} date user registered, or false for anonymous users, or
+ * null when data is not available
+ */
+ this.getRegistration = function () {
+ var registration = mw.config.get( 'wgUserRegistration' );
+ if ( this.isAnon() ) {
+ return false;
+ } else if ( registration === null ) {
+ // Information may not be available if they signed up before
+ // MW began storing this.
+ return null;
+ } else {
+ return new Date( registration );
+ }
+ };
+
+ /**
* Checks if the current user is anonymous.
*
* @return Boolean
@@ -115,7 +134,7 @@
this.sessionId = function () {
var sessionId = $.cookie( 'mediaWiki.user.sessionId' );
if ( typeof sessionId === 'undefined' || sessionId === null ) {
- sessionId = generateId();
+ sessionId = user.generateRandomSessionId();
$.cookie( 'mediaWiki.user.sessionId', sessionId, { 'expires': null, 'path': '/' } );
}
return sessionId;