Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
Conflicts:
	FSDTS/Controllers/UserController.cs
  • Loading branch information
MandarTisge committed Nov 28, 2014
2 parents 62328b4 + 7735e99 commit 18c8ee6
Show file tree
Hide file tree
Showing 30 changed files with 647 additions and 335 deletions.
8 changes: 7 additions & 1 deletion FSDTS/Business Objects/UserBO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace FSDTS.Business_Objects
using System.Security.Cryptography;
using System.Web;
using System.Web.Http;
using FSDTS.Common;
using FSDTS.Models;

/// <summary>
Expand All @@ -25,11 +26,14 @@ public class UserBO
/// </summary>
private FSDTSContext db = new FSDTSContext();



/// <summary>
/// SymmetricEncryptData method of UserBO class.
/// </summary>
/// <param name="clearText">string clearText</param>
/// <returns>Encrypted string</returns>
[FsdtsExceptionHandler]
public static string SymmetricEncryptData(string clearText)
{
////create a byte array to store the encrypted result.
Expand Down Expand Up @@ -63,12 +67,14 @@ public static string SymmetricEncryptData(string clearText)

return Convert.ToBase64String(encryptedText);
}

/// <summary>
/// SymmetricDecryptData method of UserBO class.
/// </summary>
/// <param name="cypherText">string cypherText</param>
/// <returns>Decrypted string</returns>

[FsdtsExceptionHandler]

public static string SymmetricDecryptData(string cypherText)
{
////create a byte array to store the encrypted result.
Expand Down
27 changes: 18 additions & 9 deletions FSDTS/Controllers/UserController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,11 @@ public List<User> GetUsersByOrgId(int Oid)
objuser.ManageOrganizations = Convert.ToBoolean(reader["ManageOrganizations"]);
lstUser.Add(objuser);
}

cmd.Dispose();
con.Dispose();
return lstUser;

////return db.User.Where(usr => usr.OrganizationId == Oid).OrderBy(usr => usr.UserLastName).AsQueryable();
//return db.User.Where(usr => usr.OrganizationId == Oid).OrderBy(usr => usr.UserLastName).AsQueryable();
}

/// <summary>
Expand All @@ -305,9 +304,8 @@ public IHttpActionResult PutUser(int id, User user)
Log.Error("In PutUser method: User sending id as: " + user.UserId + ". BadRequest");
return BadRequest();
}

var EncryptedPassword = UserBO.SymmetricEncryptData(user.UserPassword);
user.UserPassword = EncryptedPassword;
//var EncryptedPassword = UserBO.SymmetricEncryptData(user.UserPassword);
//user.UserPassword = EncryptedPassword;

db.Entry(user).State = EntityState.Modified;

Expand Down Expand Up @@ -343,9 +341,17 @@ public HttpResponseMessage PatchUser(int id, Delta<User> user)
{
throw new HttpResponseException(HttpStatusCode.NotFound);
}
<<<<<<< Updated upstream

var EncryptedPassword = UserBO.SymmetricEncryptData(doc.UserPassword);
doc.UserPassword = EncryptedPassword;


//var EncryptedPassword = UserBO.SymmetricEncryptData(doc.UserPassword);
//doc.UserPassword = EncryptedPassword;
>>>>>>> Stashed changes
=======
//var EncryptedPassword = UserBO.SymmetricEncryptData(doc.UserPassword);
//doc.UserPassword = EncryptedPassword;
>>>>>>> Stashed changes

user.Patch(doc);
objContext.Entry(doc).State = EntityState.Modified;
Expand Down Expand Up @@ -373,8 +379,8 @@ public IHttpActionResult PostUser(User user)
}

Log.Info(FsdtsConstants.AddingNewItem + user.UserId.ToString());
var EncryptedPassword = UserBO.SymmetricEncryptData(user.UserPassword);
user.UserPassword = EncryptedPassword;
//var EncryptedPassword = UserBO.SymmetricEncryptData(user.UserPassword);
//user.UserPassword = EncryptedPassword;
db.User.Add(user);
Log.Info(FsdtsConstants.UpdatingDatabase);
db.SaveChanges();
Expand Down Expand Up @@ -439,6 +445,9 @@ private bool UserExists(int id)
/// <param name="userName">string userName</param>
/// <param name="userPassword">string userPassword</param>
/// <returns>HttpResponseMessage Success/Failure</returns>
=======
[ResponseType(typeof(User))]
>>>>>>> Stashed changes
[FsdtsExceptionHandler]
public HttpResponseMessage Login(User userobj)
{
Expand Down
2 changes: 1 addition & 1 deletion FSDTS/Models/CommonProgramsGrouping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class CommonProgramsGrouping
/// <summary>
/// Gets or sets common grouping name.
/// </summary>
[FSDTS.Common.CustomValidators.Unique(ErrorMessage = "Common grouping name already exists.")]
//[FSDTS.Common.CustomValidators.Unique(ErrorMessage = "Common grouping name already exists.")]
public string CommonProgramsGroupingName { get; set; }

/// <summary>
Expand Down
8 changes: 8 additions & 0 deletions FSDTS/Providers/ApplicationOAuthProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
using Microsoft.Owin.Security;
using Microsoft.Owin.Security.Cookies;
using Microsoft.Owin.Security.OAuth;
using FSDTS.Controllers;
using FSDTS.Models;
using System.Web;
using System.Net.Http;

namespace FSDTS.Providers
{
Expand Down Expand Up @@ -36,6 +40,10 @@ public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwner
{
//context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" });

UserController obj = new UserController();

HttpResponseMessage response = obj.Login(context.UserName, context.Password);

using (UserManager<IdentityUser> userManager = _userManagerFactory())
{
IdentityUser user = await userManager.FindAsync(context.UserName, context.Password);
Expand Down
25 changes: 22 additions & 3 deletions FSDTSUI/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ function ($routeProvider, $locationProvider, appConstants) {
when('/login', {
templateUrl: 'app/views/common/login.html',
controller: 'authController',
data: {
'actionType': appConstants.OPERATION_TYPE.LOGIN
},
activePage: 'loginPage',
label: 'login'
}).
Expand Down Expand Up @@ -214,15 +217,31 @@ function ($routeProvider, $locationProvider, appConstants) {
authorizedRoles: [appConstants.USER_ROLES.ADMIN, appConstants.USER_ROLES.USER]
}
}).
when('/aboutUs', {
when('/forgotPassword', {
templateUrl: 'app/views/common/forgotPassword.html',
controller: 'authController',
data: {
'actionType': appConstants.OPERATION_TYPE.FORGOTPASSWORD
}
}).
when('/resetPassword', {
templateUrl: 'app/views/common/resetPassword.html',
controller: 'authController',
data: {
'actionType': appConstants.OPERATION_TYPE.RESETPASSWORD
}
}).
when('/aboutUs', {
templateUrl: 'app/views/common/aboutUs.html',
activePage: 'AboutUs',
label: 'AboutUs'
}).when('/aboutIndustry', {
}).
when('/aboutIndustry', {
templateUrl: 'app/views/common/aboutIndustry.html',
activePage: 'About Industry',
label: 'About Industry'
}).when('/welcome', {
}).
when('/welcome', {
templateUrl: 'app/views/common/welcome.html',
activePage: 'Welcome',
label: 'Welcome',
Expand Down
5 changes: 4 additions & 1 deletion FSDTSUI/app/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ fsdtsApp.constant('appConstants', {
'OPERATION_TYPE': {
'ADD': '1',
'EDIT': '2',
'DELETE': '3'
'DELETE': '3',
'LOGIN': 4,
'FORGOTPASSWORD': 5,
'RESETPASSWORD':6
},
'USER_ROLES': {
'ALL': '*',
Expand Down
32 changes: 26 additions & 6 deletions FSDTSUI/app/controllers/adminSite/courseController.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,25 @@ Is used to provide all event handling logic for course view i.e course.html
'use strict';
fsdtsApp.controller('courseController', ['$scope', '$routeParams', 'appConstants', 'courseManagementService', '$location', 'userProfileService',
function ($scope, $routeParams, appConstants, courseManagementService, $location, userProfileService) {

//Submit button click handler
$scope.onSubmit = function (event) {
event.preventDefault();
if ($scope.validator.validate()) { // code for validation
if ($scope.validator.validate()) { //code for validation
$scope.validationClass = "valid";
$scope.confirmWindowOption.actionType = "Submit";
$scope.confirmWindowOption.showConfirm = true;
if ($routeParams.actionType === appConstants.OPERATION_TYPE.ADD) {
showConfirmWindow();
} else if ($routeParams.actionType === appConstants.OPERATION_TYPE.EDIT) {
if (isDirtyForm($scope.courseInfo)) {//Check dirty form
showConfirmWindow();
} else {
showErrorWindow(['Edit form data before submit.']);
}
}

} else {
$scope.validationClass = "invalid";
}

};

//On cancel button click handler
Expand All @@ -37,13 +45,23 @@ function ($scope, $routeParams, appConstants, courseManagementService, $location
}
};

var isDirtyForm = function (courseInfo) {
return !angular.equals(courseInfo, masterCourseInfo);
};

//Showing error window
var showErrorWindow = function (errorMessages) {
$scope.errorWindowOption.showError = true;
$scope.errorWindowOption.errorMessages = errorMessages;
$scope.showSpin = false;
};

//Show confirm window
var showConfirmWindow = function () {
$scope.confirmWindowOption.actionType = "Submit";
$scope.confirmWindowOption.showConfirm = true;
};

//Reset the form control
var resetForm = function () {
$scope.courseInfo = {
Expand Down Expand Up @@ -80,12 +98,14 @@ function ($scope, $routeParams, appConstants, courseManagementService, $location
});
};

var masterCourseInfo;
//Service call to get course details
var getCourse = function () {
//Show spin window
$scope.showSpin = true;
courseManagementService.getCourseDetails(userProfileService.profile.params.courseId).then(function (result) {
$scope.courseInfo = courseManagementService.populateCourseModel(result);
masterCourseInfo = angular.copy($scope.courseInfo);
//Show spin window
$scope.showSpin = false;
}, function (error) {
Expand All @@ -103,8 +123,8 @@ function ($scope, $routeParams, appConstants, courseManagementService, $location
};

$scope.errorWindowOption = {
showError:false,
errorMessage:null
showError: false,
errorMessage: null
};
//#endregion

Expand Down
24 changes: 22 additions & 2 deletions FSDTSUI/app/controllers/adminSite/credentialController.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,16 @@ function ($scope, $routeParams, appConstants, credentialManagementService, $loca
event.preventDefault();
if ($scope.validator.validate()) { //code for validation
$scope.validationClass = "valid";
$scope.confirmWindowOption.actionType = "Submit";
$scope.confirmWindowOption.showConfirm = true;
if ($routeParams.actionType === appConstants.OPERATION_TYPE.ADD) {
showConfirmWindow();
} else if ($routeParams.actionType === appConstants.OPERATION_TYPE.EDIT) {
if (isDirtyForm($scope.credentialInfo)) {//Check dirty form
showConfirmWindow();
} else {
showErrorWindow(['Edit form data before submit.']);
}
}

} else {
$scope.validationClass = "invalid";
}
Expand All @@ -37,13 +45,23 @@ function ($scope, $routeParams, appConstants, credentialManagementService, $loca
}
};

var isDirtyForm = function (credentialInfo) {
return !angular.equals(credentialInfo, masterCredentialInfo);
};

//Showing error window
var showErrorWindow = function (errorMessages) {
$scope.errorWindowOption.showError = true;
$scope.errorWindowOption.errorMessages = errorMessages;
$scope.showSpin = false;
};

//Show confirm window
var showConfirmWindow = function () {
$scope.confirmWindowOption.actionType = "Submit";
$scope.confirmWindowOption.showConfirm = true;
};

//Reset the form control
var resetForm = function () {
$scope.credentialInfo = {
Expand Down Expand Up @@ -80,12 +98,14 @@ function ($scope, $routeParams, appConstants, credentialManagementService, $loca
});
};

var masterCredentialInfo;
//Service call to get credential details
var getCredential = function () {
//Show spin window
$scope.showSpin = true;
credentialManagementService.getCredentialDetails(userProfileService.profile.params.credentialId).then(function (result) {
$scope.credentialInfo = credentialManagementService.populateCredentialModel(result);
masterCredentialInfo = angular.copy($scope.credentialInfo);
//Hide spin window
$scope.showSpin = false;
}, function (error) {
Expand Down
Loading

0 comments on commit 18c8ee6

Please sign in to comment.