source: trunk/LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Controller/Rpc.pm @ 2006

Last change on this file since 2006 was 870, checked in by nanardon, 13 years ago
  • add XML::RPC interface to website
  • add XML::RPC clients project
    • add tools to allow user to change their password
  • Property svn:keywords set to Id
File size: 1.4 KB
Line 
1package LATMOS::Accounts::Web::Controller::Rpc;
2use Moose;
3use namespace::autoclean;
4$RPC::XML::ENCODING = 'utf-8';
5
6BEGIN {extends 'Catalyst::Controller'; }
7
8=head1 NAME
9
10LATMOS::Accounts::Web::Controller::Rpc - Catalyst Controller
11
12=head1 DESCRIPTION
13
14Catalyst Controller.
15
16=head1 METHODS
17
18=cut
19
20
21=head2 index
22
23=cut
24
25sub _begin : Private {
26    my ($self, $c) = @_;
27}
28
29sub index : Public {
30    my ($self, $c) = @_;
31    $c->xmlrpc;
32}
33
34sub ech : XMLRPC('ech.ech') {
35    my ( $self, $c, @args ) = @_;
36    return RPC::XML::fault->new( 400, "No input!" ) unless
37    @args;
38    return join ' ', @args;
39}
40sub user_change_password : XMLRPC('user.change_password') {
41    my ( $self, $c, $username, $oldpasswd, $newpasswd ) = @_;
42    return RPC::XML::fault->new( 400, "No input!" ) unless $newpasswd;
43
44    $c->authenticate({
45        username => $username,
46        password => $oldpasswd,
47    }) or return RPC::XML::fault->new( 400, "Cannot authenticate" );
48
49    my $msg = $c->forward('/users/change_password', [ $username, $newpasswd ]);
50    if ($msg) {
51        return RPC::XML::fault->new( 400, "Error: $msg" );
52    } else {
53        return "Password changed";
54    }
55}
56
57
58sub end : Private {}
59
60=head1 AUTHOR
61
62Olivier Thauvin
63
64=head1 LICENSE
65
66This library is free software. You can redistribute it and/or modify
67it under the same terms as Perl itself.
68
69=cut
70
71__PACKAGE__->meta->make_immutable;
72
731;
Note: See TracBrowser for help on using the repository browser.