mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-05-06 20:06:53 +02:00
improve authentication
This commit is contained in:
@@ -9,6 +9,7 @@ package sonia.scm.api.rest;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.ScmState;
|
||||
import sonia.scm.group.Group;
|
||||
import sonia.scm.repository.Repository;
|
||||
|
||||
@@ -43,7 +44,7 @@ public class JsonJaxbContextResolver implements ContextResolver<JAXBContext>
|
||||
{
|
||||
this.context = new JSONJAXBContext(
|
||||
JSONConfiguration.mapped().rootUnwrapping(true).arrays(
|
||||
"member", "groups", "permissions").nonStrings(
|
||||
"member", "groups", "permissions", "repositoryTypes").nonStrings(
|
||||
"readable", "writeable", "groupPermission").build(), types.toArray(
|
||||
new Class[0]));
|
||||
}
|
||||
@@ -73,5 +74,5 @@ public class JsonJaxbContextResolver implements ContextResolver<JAXBContext>
|
||||
|
||||
/** Field description */
|
||||
private List<Class> types = Arrays.asList(new Class[] { Group.class,
|
||||
Repository.class });
|
||||
Repository.class, ScmState.class });
|
||||
}
|
||||
|
||||
@@ -9,9 +9,10 @@ package sonia.scm.api.rest.resources;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.repository.RepositoryType;
|
||||
import sonia.scm.SCMContext;
|
||||
import sonia.scm.ScmState;
|
||||
import sonia.scm.User;
|
||||
import sonia.scm.repository.RepositoryType;
|
||||
import sonia.scm.security.Authenticator;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
@@ -41,15 +42,6 @@ import javax.ws.rs.core.Response;
|
||||
public class AuthenticationResource
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
private static final RepositoryType[] types = new RepositoryType[] {
|
||||
new RepositoryType("hg",
|
||||
"Mercurial"),
|
||||
new RepositoryType("svn", "Subversion"),
|
||||
new RepositoryType("git", "Git") };
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -120,7 +112,9 @@ public class AuthenticationResource
|
||||
ScmState state = new ScmState();
|
||||
|
||||
state.setUser(user);
|
||||
state.setRepositoryTypes(types);
|
||||
state.setRepositoryTypes(
|
||||
SCMContext.getContext().getRepositoryTypes().toArray(
|
||||
new RepositoryType[0]));
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
@@ -4,14 +4,23 @@
|
||||
*/
|
||||
|
||||
var debug = true;
|
||||
|
||||
var state = null;
|
||||
|
||||
/*var repositoryTypes = [ ['Mercurial', 'hg'], ['Subversion','svn'], ['Git','git'] ];*/
|
||||
var authCallbacks = [];
|
||||
|
||||
var repositoryTypeStore = new Ext.data.JsonStore({
|
||||
id: 1,
|
||||
fields: [ 'displayName', 'name' ]
|
||||
});
|
||||
|
||||
var restUrl = "api/rest/";
|
||||
var restUrl = "api/rest/";
|
||||
|
||||
function loadState(s){
|
||||
state = s;
|
||||
console.debug( s );
|
||||
repositoryTypeStore.loadData(state.repositoryTypes);
|
||||
Ext.each(authCallbacks, function(callback){
|
||||
if ( Ext.isFunction(callback) ){
|
||||
callback(state);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -113,20 +113,21 @@ Ext.onReady(function(){
|
||||
repositoryLink.on('click', addRepositoryPanel);
|
||||
}
|
||||
|
||||
// create menu after login
|
||||
authCallbacks.push( createMainMenu );
|
||||
|
||||
Ext.Ajax.request({
|
||||
url: restUrl + 'authentication.json',
|
||||
method: 'GET',
|
||||
success: function(response){
|
||||
state = Ext.decode(response.responseText);
|
||||
console.debug( state );
|
||||
repositoryTypeStore.loadData(state.repositoryTypes);
|
||||
createMainMenu();
|
||||
var s = Ext.decode(response.responseText);
|
||||
loadState(s);
|
||||
},
|
||||
failure: function(){
|
||||
var loginWin = new Sonia.login.Window();
|
||||
loginWin.on('success', function(){
|
||||
/*loginWin.on('success', function(){
|
||||
createMainMenu();
|
||||
});
|
||||
});*/
|
||||
loginWin.show();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -63,8 +63,8 @@ Sonia.login.Form = Ext.extend(Ext.FormPanel,{
|
||||
waitTitle:'Connecting',
|
||||
waitMsg:'Sending data...',
|
||||
|
||||
success: function(){
|
||||
Ext.Msg.alert('Login Success!');
|
||||
success: function(form, action){
|
||||
loadState( action.result );
|
||||
},
|
||||
|
||||
failure: function(form, action){
|
||||
|
||||
Reference in New Issue
Block a user