+
+exports.getTokens = function (req, res, next) {
+ tokenStore.getApiTokens(function (error, result) {
+ if (error) return next(new HttpError(500, error));
+
+ next(new HttpSuccess(200, { accessTokens: result }));
+ });
+};
+
+exports.createToken = function (req, res, next) {
+ var accessToken = API_TOKEN_PREFIX + uuid();
+
+ tokenStore.set(accessToken, req.user, function (error) {
+ if (error) return next(new HttpError(500, error));
+
+ next(new HttpSuccess(201, { accessToken: accessToken }));
+ });
+};
+
+exports.delToken = function (req, res, next) {
+ tokenStore.del(req.params.token, function (error) {
+ if (error) console.error(error);
+
+ next(new HttpSuccess(200, {}));
+ });
+};
+
+// webdav usermanager
+exports.WebdavUserManager = WebdavUserManager;
+
+// This implements the required interface only for the Basic Authentication for webdav-server
+function WebdavUserManager() {};
+
+WebdavUserManager.prototype.getDefaultUser = function (callback) {
+ // this is only a dummy user, since we always require authentication
+ var user = {
+ username: 'DefaultUser',
+ password: null,
+ isAdministrator: false,
+ isDefaultUser: true,
+ uid: 'DefaultUser'
+ };
+
+ callback(user);
+};
+
+WebdavUserManager.prototype.getUserByNamePassword = function (username, password, callback) {
+ verifyUser(username, password, function (error, user) {
+ if (error) return callback(webdavErrors.UserNotFound);
+
+ callback(null, {
+ username: user.username,
+ isAdministrator: true,
+ isDefaultUser: false,
+ uid: user.username
+ });
+ });
+};