Created
August 6, 2015 03:11
-
-
Save MerrittMelker/cb0cef69c6b7b9dfb1cc to your computer and use it in GitHub Desktop.
Login Service For Sitefinity Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Reflection; | |
using System.Runtime.InteropServices; | |
using System.Web; | |
using Ks.Sf.Web.Bootstrap; | |
using Telerik.Sitefinity.Frontend.Mvc.Infrastructure.Controllers.Attributes; | |
[assembly: ControllerContainer] | |
// General Information about an assembly is controlled through the following | |
// set of attributes. Change these attribute values to modify the information | |
// associated with an assembly. | |
[assembly: PreApplicationStartMethod(typeof(CustomBootstrapper), "PreApplicationStart")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using MyNamespace; | |
using Telerik.Sitefinity.Abstractions; | |
using Telerik.Sitefinity.Data; | |
using Telerik.Sitefinity.Services; | |
namespace Ks.Sf.Web.Bootstrap | |
{ | |
public static class CustomBootstrapper | |
{ | |
public static void PreApplicationStart() | |
{ | |
Bootstrapper.Initialized += OnBootstrapperInitialized; | |
} | |
private static void OnBootstrapperInitialized(object sender, ExecutedEventArgs e) | |
{ | |
if (e.CommandName == "RegisterRoutes") | |
{ | |
SystemManager.RegisterWebService(typeof (LoginService), "CustomServices/ProductionsService"); | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.ServiceModel; | |
using System.ServiceModel.Web; | |
namespace MyNamespace | |
{ | |
[ServiceContract] | |
public interface ILoginService | |
{ | |
[OperationContract] | |
[WebInvoke(ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest, Method = "POST")] | |
bool Login(string user, string password); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.ServiceModel; | |
using System.ServiceModel.Activation; | |
using Telerik.Sitefinity.Security; | |
using Telerik.Sitefinity.Security.Model; | |
namespace MyNamespace | |
{ | |
[ServiceBehavior(IncludeExceptionDetailInFaults = true, InstanceContextMode = InstanceContextMode.Single, | |
ConcurrencyMode = ConcurrencyMode.Single)] | |
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)] | |
public class LoginService : ILoginService | |
{ | |
public bool Login(string userName, string password) | |
{ | |
User user; | |
var result = SecurityManager.AuthenticateUser( | |
"Default or the one u want to use, name is in security config", | |
userName, | |
password, | |
false, | |
out user); | |
return user != null; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment