Merge "Remove not used private member variable mParserWarnings from OutputPage"
[mediawiki.git] / resources / src / mediawiki / api / user.js
blobe7b4b6d54fca752e49615df045b5af5ca3b1d97b
1 /**
2  * @class mw.Api.plugin.user
3  * @since 1.27
4  */
5 ( function ( mw, $ ) {
7         $.extend( mw.Api.prototype, {
9                 /**
10                  * Get the current user's groups and rights.
11                  *
12                  * @return {jQuery.Promise}
13                  * @return {Function} return.done
14                  * @return {Object} return.done.userInfo
15                  * @return {string[]} return.done.userInfo.groups User groups that the current user belongs to
16                  * @return {string[]} return.done.userInfo.rights Current user's rights
17                  */
18                 getUserInfo: function () {
19                         return this.get( {
20                                 action: 'query',
21                                 meta: 'userinfo',
22                                 uiprop: [ 'groups', 'rights' ]
23                         } ).then( function ( data ) {
24                                 if ( data.query && data.query.userinfo ) {
25                                         return data.query.userinfo;
26                                 }
27                                 return $.Deferred().reject().promise();
28                         } );
29                 }
30         } );
32         /**
33          * @class mw.Api
34          * @mixins mw.Api.plugin.user
35          */
37 }( mediaWiki, jQuery ) );