Free cookie consent management tool by TermsFeed Policy Generator

source: branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Hubs/UserInfoHub.cs @ 13862

Last change on this file since 13862 was 13862, checked in by jlodewyc, 8 years ago

#2582 Start angular OKB manager, data loaded

File size: 2.5 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22
23using HeuristicLab.Clients.Hive.WebJobManager.Controllers;
24using HeuristicLab.Clients.Hive.WebJobManager.Services;
25using HeuristicLab.Clients.Hive.WebJobManager.Services.Imports;
26using HeuristicLab.Clients.Hive.WebJobManager.ViewModels.User;
27using Microsoft.AspNetCore.SignalR;
28using System;
29
30namespace HeuristicLab.Clients.Hive.WebJobManager.Hubs
31{
32    /// <summary>
33    /// Small SignalR hub to change the password from a user
34    /// </summary>
35    public class UserInfoHub: Hub
36    {
37        private WebLoginService weblog;
38        private Guid userId;
39        private AccessAdministrationClient aac;
40        /// <summary>
41        /// Loads required services
42        /// </summary>
43        private void loader()
44        {
45            weblog = WebLoginService.Instance;
46            string uid = Context.QueryString["userid"];
47            if (uid == null || uid == "" || Guid.Parse(uid) == Guid.Empty)
48            {
49                userId = Guid.Empty;
50            }
51            else
52            {
53                userId = Guid.Parse(uid);
54                aac = weblog.getAccessAdminClient(userId);
55            }
56        }
57        /// <summary>
58        /// Request to change pass
59        /// </summary>
60        /// <param name="user">User id</param>
61        public void resetPassword(string user)
62        {
63            loader();
64            Guid userid = Guid.Parse(user);
65            Access.User u = new UserViewModel(aac, weblog.getCurrentUser(userId)).refreshUsers().getUserById(userid);
66            var pass = aac.resetPassword(userid);
67            UserController.sendPassmail(u, pass);//Send mail + show pass           
68            Clients.Caller.showNewPass(pass);
69        }
70    }
71}
Note: See TracBrowser for help on using the repository browser.