Skip to content

Instantly share code, notes, and snippets.

@MerrittMelker
Created August 6, 2015 03:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MerrittMelker/cb0cef69c6b7b9dfb1cc to your computer and use it in GitHub Desktop.
Save MerrittMelker/cb0cef69c6b7b9dfb1cc to your computer and use it in GitHub Desktop.
Login Service For Sitefinity Example
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")]
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");
}
}
}
}
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);
}
}
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